mirror of
https://github.com/moparisthebest/Yaaic
synced 2024-11-26 10:52:16 -05:00
Replace all tabs with four spaces!
This commit is contained in:
parent
f3f195f631
commit
02b7ec1741
@ -20,12 +20,12 @@ 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/>.
|
||||||
-->
|
-->
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="org.yaaic"
|
package="org.yaaic"
|
||||||
android:versionCode="7"
|
android:versionCode="7"
|
||||||
android:versionName="0.6">
|
android:versionName="0.6">
|
||||||
<application
|
<application
|
||||||
android:icon="@drawable/icon"
|
android:icon="@drawable/icon"
|
||||||
android:label="Yaaic">
|
android:label="Yaaic">
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.ServersActivity"
|
android:name=".activity.ServersActivity"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
@ -38,12 +38,12 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
<activity
|
<activity
|
||||||
android:name=".activity.AddServerActivity"
|
android:name=".activity.AddServerActivity"
|
||||||
android:label="@string/add_server_label">
|
android:label="@string/add_server_label">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.VIEW" />
|
<action android:name="android.intent.action.VIEW" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
<category android:name="android.intent.category.BROWSABLE" />
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
<data android:scheme="irc"/>
|
<data android:scheme="irc"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.ConversationActivity"
|
android:name=".activity.ConversationActivity"
|
||||||
@ -69,25 +69,25 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
android:theme="@android:style/Theme.Dialog">
|
android:theme="@android:style/Theme.Dialog">
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.AddAliasActivity"
|
android:name=".activity.AddAliasActivity"
|
||||||
android:theme="@android:style/Theme.Dialog">
|
android:theme="@android:style/Theme.Dialog">
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.AddChannelActivity"
|
android:name=".activity.AddChannelActivity"
|
||||||
android:theme="@android:style/Theme.Dialog">
|
android:theme="@android:style/Theme.Dialog">
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.AddCommandsActivity"
|
android:name=".activity.AddCommandsActivity"
|
||||||
android:theme="@android:style/Theme.Dialog">
|
android:theme="@android:style/Theme.Dialog">
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.MessageActivity"
|
android:name=".activity.MessageActivity"
|
||||||
android:theme="@android:style/Theme.Dialog">
|
android:theme="@android:style/Theme.Dialog">
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.UserActivity"
|
android:name=".activity.UserActivity"
|
||||||
android:theme="@android:style/Theme.Dialog">
|
android:theme="@android:style/Theme.Dialog">
|
||||||
</activity>
|
</activity>
|
||||||
<service android:name=".irc.IRCService"></service>
|
<service android:name=".irc.IRCService"></service>
|
||||||
</application>
|
</application>
|
||||||
<uses-sdk android:minSdkVersion="3" />
|
<uses-sdk android:minSdkVersion="3" />
|
||||||
|
@ -26,50 +26,50 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
android:padding="10px">
|
android:padding="10px">
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Yaaic"
|
android:text="Yaaic"
|
||||||
android:textSize="16px"
|
android:textSize="16px"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:textColor="#FF6CB600" />
|
android:textColor="#FF6CB600" />
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:gravity="center_horizontal">
|
android:gravity="center_horizontal">
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/app_full_name"
|
android:text="@string/app_full_name"
|
||||||
android:textSize="10px" />
|
android:textSize="10px" />
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text=" - " />
|
android:text=" - " />
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/app_version"
|
android:text="@string/app_version"
|
||||||
android:textSize="10px" />
|
android:textSize="10px" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/app_copyright"
|
android:text="@string/app_copyright"
|
||||||
android:textSize="12px"
|
android:textSize="12px"
|
||||||
android:gravity="center_horizontal" />
|
android:gravity="center_horizontal" />
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/app_homepage"
|
android:text="@string/app_homepage"
|
||||||
android:linksClickable="true"
|
android:linksClickable="true"
|
||||||
android:autoLink="web"
|
android:autoLink="web"
|
||||||
android:textColorLink="#FF6CB600"
|
android:textColorLink="#FF6CB600"
|
||||||
android:textSize="16px"
|
android:textSize="16px"
|
||||||
android:gravity="center_horizontal" />
|
android:gravity="center_horizontal" />
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/licence_info"
|
android:text="@string/licence_info"
|
||||||
android:textSize="12px" />
|
android:textSize="12px" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@ -1,48 +1,48 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent">
|
android:layout_height="fill_parent">
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/alias_add_description"
|
android:text="@string/alias_add_description"
|
||||||
android:padding="5px" />
|
android:padding="5px" />
|
||||||
<ListView
|
<ListView
|
||||||
android:id="@+id/aliases"
|
android:id="@+id/aliases"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/alias"
|
android:id="@+id/alias"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:layout_weight="1" />
|
android:layout_weight="1" />
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/add"
|
android:id="@+id/add"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:enabled="false"
|
android:enabled="false"
|
||||||
android:text="Add" />
|
android:text="Add" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
<Button
|
<Button
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/ok"
|
android:id="@+id/ok"
|
||||||
android:text="Ok" />
|
android:text="Ok" />
|
||||||
<Button
|
<Button
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/cancel"
|
android:id="@+id/cancel"
|
||||||
android:text="Cancel" />
|
android:text="Cancel" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/host"
|
android:id="@+id/host"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="7px"
|
android:padding="7px"
|
||||||
android:text=""
|
android:text=""
|
||||||
android:textSize="12px" />
|
android:textSize="12px" />
|
||||||
|
@ -20,49 +20,49 @@ 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
|
<LinearLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent">
|
android:layout_height="fill_parent">
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/channel_add_description"
|
android:text="@string/channel_add_description"
|
||||||
android:padding="5px" />
|
android:padding="5px" />
|
||||||
<ListView
|
<ListView
|
||||||
android:id="@+id/channels"
|
android:id="@+id/channels"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/channel"
|
android:id="@+id/channel"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:text="#"
|
android:text="#"
|
||||||
android:layout_weight="1" />
|
android:layout_weight="1" />
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/add"
|
android:id="@+id/add"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/action_add" />
|
android:text="@string/action_add" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
<Button
|
<Button
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/ok"
|
android:id="@+id/ok"
|
||||||
android:text="@string/action_ok" />
|
android:text="@string/action_ok" />
|
||||||
<Button
|
<Button
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/cancel"
|
android:id="@+id/cancel"
|
||||||
android:text="@string/action_cancel" />
|
android:text="@string/action_cancel" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@ -20,10 +20,10 @@ 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"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
android:padding="3px">
|
android:padding="3px">
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/channel"
|
android:id="@+id/channel"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -20,9 +20,9 @@ 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/>.
|
||||||
-->
|
-->
|
||||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/host"
|
android:id="@+id/host"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="7px"
|
android:padding="7px"
|
||||||
android:text=""
|
android:text=""
|
||||||
android:textSize="12px" />
|
android:textSize="12px" />
|
@ -20,49 +20,49 @@ 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
|
<LinearLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent">
|
android:layout_height="fill_parent">
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/command_add_description"
|
android:text="@string/command_add_description"
|
||||||
android:padding="5px" />
|
android:padding="5px" />
|
||||||
<ListView
|
<ListView
|
||||||
android:id="@+id/commands"
|
android:id="@+id/commands"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/command"
|
android:id="@+id/command"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:text="/"
|
android:text="/"
|
||||||
android:layout_weight="1" />
|
android:layout_weight="1" />
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/add"
|
android:id="@+id/add"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/action_add" />
|
android:text="@string/action_add" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
<Button
|
<Button
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/ok"
|
android:id="@+id/ok"
|
||||||
android:text="@string/action_ok" />
|
android:text="@string/action_ok" />
|
||||||
<Button
|
<Button
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/cancel"
|
android:id="@+id/cancel"
|
||||||
android:text="@string/action_cancel" />
|
android:text="@string/action_cancel" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@ -20,9 +20,9 @@ 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/>.
|
||||||
-->
|
-->
|
||||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/host"
|
android:id="@+id/host"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="7px"
|
android:padding="7px"
|
||||||
android:text=""
|
android:text=""
|
||||||
android:textSize="12px" />
|
android:textSize="12px" />
|
@ -26,56 +26,56 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
android:background="#ff181818">
|
android:background="#ff181818">
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="3px">
|
android:padding="3px">
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/status"
|
android:id="@+id/status"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:src="@drawable/disconnected"/>
|
android:src="@drawable/disconnected"/>
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/title"
|
android:id="@+id/title"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingLeft="3px"
|
android:paddingLeft="3px"
|
||||||
android:textSize="12px"
|
android:textSize="12px"
|
||||||
android:layout_weight="1" />
|
android:layout_weight="1" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<ViewSwitcher
|
<ViewSwitcher
|
||||||
android:id="@+id/switcher"
|
android:id="@+id/switcher"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1">
|
android:layout_weight="1">
|
||||||
<Gallery
|
<Gallery
|
||||||
android:id="@+id/deck"
|
android:id="@+id/deck"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
android:layout_margin="0px"
|
android:layout_margin="0px"
|
||||||
android:spacing="5px"
|
android:spacing="5px"
|
||||||
android:unselectedAlpha="100"/>
|
android:unselectedAlpha="100"/>
|
||||||
</ViewSwitcher>
|
</ViewSwitcher>
|
||||||
<org.yaaic.view.ConversationSwitcher
|
<org.yaaic.view.ConversationSwitcher
|
||||||
android:id="@+id/dots"
|
android:id="@+id/dots"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/input"
|
android:id="@+id/input"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:imeOptions="actionSend" />
|
android:imeOptions="actionSend" />
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/speech"
|
android:id="@+id/speech"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:drawableLeft="@android:drawable/ic_btn_speak_now"
|
android:drawableLeft="@android:drawable/ic_btn_speak_now"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@ -20,21 +20,21 @@ 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
|
<LinearLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
android:padding="5px">
|
android:padding="5px">
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/channel"
|
android:id="@+id/channel"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:ems="10"
|
android:ems="10"
|
||||||
android:text="#" />
|
android:text="#" />
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/join"
|
android:id="@+id/join"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/join" />
|
android:text="@string/join" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@ -20,21 +20,21 @@ 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
|
<LinearLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent">
|
android:layout_height="fill_parent">
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/message"
|
android:id="@+id/message"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="10px"
|
android:padding="10px"
|
||||||
android:autoLink="all"
|
android:autoLink="all"
|
||||||
android:linksClickable="true" />
|
android:linksClickable="true" />
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/tools"
|
android:id="@+id/tools"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent">
|
android:layout_height="fill_parent">
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@ -20,21 +20,21 @@ 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/>.
|
||||||
-->
|
-->
|
||||||
<shape
|
<shape
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:shape="rectangle">
|
android:shape="rectangle">
|
||||||
<stroke
|
<stroke
|
||||||
android:width="1px"
|
android:width="1px"
|
||||||
android:color="#55ffffff" />
|
android:color="#55ffffff" />
|
||||||
<padding
|
<padding
|
||||||
android:left="3px"
|
android:left="3px"
|
||||||
android:top="3px"
|
android:top="3px"
|
||||||
android:right="3px"
|
android:right="3px"
|
||||||
android:bottom="3px" />
|
android:bottom="3px" />
|
||||||
<solid
|
<solid
|
||||||
android:color="#cc000000" />
|
android:color="#cc000000" />
|
||||||
<corners
|
<corners
|
||||||
android:bottomRightRadius="10dp"
|
android:bottomRightRadius="10dp"
|
||||||
android:bottomLeftRadius="10dp"
|
android:bottomLeftRadius="10dp"
|
||||||
android:topLeftRadius="10dp"
|
android:topLeftRadius="10dp"
|
||||||
android:topRightRadius="10dp" />
|
android:topRightRadius="10dp" />
|
||||||
</shape>
|
</shape>
|
@ -20,75 +20,75 @@ 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/>.
|
||||||
-->
|
-->
|
||||||
<ScrollView
|
<ScrollView
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
android:scrollbarStyle="outsideInset">
|
android:scrollbarStyle="outsideInset">
|
||||||
<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="fill_parent">
|
||||||
<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:background="#ff333333"
|
||||||
android:textSize="14px"
|
android:textSize="14px"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:padding="3px"
|
android:padding="3px"
|
||||||
android:layout_margin="2px" />
|
android:layout_margin="2px" />
|
||||||
<TextView
|
<TextView
|
||||||
android:text="@string/server_title"
|
android:text="@string/server_title"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/title"
|
android:id="@+id/title"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:singleLine="true" />
|
android:singleLine="true" />
|
||||||
<TextView
|
<TextView
|
||||||
android:text="@string/server_host"
|
android:text="@string/server_host"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/host"
|
android:id="@+id/host"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:singleLine="true" />
|
android:singleLine="true" />
|
||||||
<TextView
|
<TextView
|
||||||
android:text="@string/server_port"
|
android:text="@string/server_port"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/port"
|
android:id="@+id/port"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:minEms="6"
|
android:minEms="6"
|
||||||
android:text="6667" />
|
android:text="6667" />
|
||||||
<TextView
|
<TextView
|
||||||
android:text="@string/server_password"
|
android:text="@string/server_password"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/password"
|
android:id="@+id/password"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:password="true"
|
android:password="true"
|
||||||
android:minEms="10"
|
android:minEms="10"
|
||||||
android:maxEms="10" />
|
android:maxEms="10" />
|
||||||
<CheckBox
|
<CheckBox
|
||||||
android:id="@+id/autoconnect"
|
android:id="@+id/autoconnect"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/server_port"
|
android:text="@string/server_port"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
<CheckBox
|
<CheckBox
|
||||||
android:id="@+id/useSSL"
|
android:id="@+id/useSSL"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/server_useSSL" />
|
android:text="@string/server_useSSL" />
|
||||||
<!-- ############################################################################ -->
|
<!-- ############################################################################ -->
|
||||||
<TextView
|
<TextView
|
||||||
android:text="@string/user"
|
android:text="@string/user"
|
||||||
@ -134,62 +134,62 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
android:text=""
|
android:text=""
|
||||||
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:background="#ff333333"
|
||||||
android:textSize="14px"
|
android:textSize="14px"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:padding="3px"
|
android:padding="3px"
|
||||||
android:layout_margin="2px" />
|
android:layout_margin="2px" />
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/channels"
|
android:id="@+id/channels"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/channels" />
|
android:text="@string/channels" />
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/commands"
|
android:id="@+id/commands"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
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:background="#ff333333"
|
||||||
android:textSize="14px"
|
android:textSize="14px"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:padding="3px"
|
android:padding="3px"
|
||||||
android:layout_margin="2px" />
|
android:layout_margin="2px" />
|
||||||
<TextView
|
<TextView
|
||||||
android:text="@string/charset"
|
android:text="@string/charset"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
<Spinner
|
<Spinner
|
||||||
android:id="@+id/charset"
|
android:id="@+id/charset"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:prompt="@string/select_charset" />
|
android:prompt="@string/select_charset" />
|
||||||
<!-- ############################################################################ -->
|
<!-- ############################################################################ -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingTop="10px">
|
android:paddingTop="10px">
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/add"
|
android:id="@+id/add"
|
||||||
android:text="@string/server_save"
|
android:text="@string/server_save"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1" />
|
android:layout_weight="1" />
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/cancel"
|
android:id="@+id/cancel"
|
||||||
android:text="@string/action_cancel"
|
android:text="@string/action_cancel"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="0" />
|
android:layout_weight="0" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
@ -35,17 +35,17 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:paddingLeft="5px">
|
android:paddingLeft="5px">
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/title"
|
android:id="@+id/title"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text=""
|
android:text=""
|
||||||
android:textSize="16px" />
|
android:textSize="16px" />
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/host"
|
android:id="@+id/host"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text=""
|
android:text=""
|
||||||
android:textSize="12px" />
|
android:textSize="12px" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@ -20,67 +20,67 @@ 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
|
<LinearLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent">
|
android:layout_height="fill_parent">
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/nickname"
|
android:id="@+id/nickname"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="10px"
|
android:padding="10px"
|
||||||
android:autoLink="all"
|
android:autoLink="all"
|
||||||
android:linksClickable="true"
|
android:linksClickable="true"
|
||||||
android:textSize="20px" />
|
android:textSize="20px" />
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/op"
|
android:id="@+id/op"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:text="@string/button_op" />
|
android:text="@string/button_op" />
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/deop"
|
android:id="@+id/deop"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:text="@string/button_deop" />
|
android:text="@string/button_deop" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/voice"
|
android:id="@+id/voice"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:text="@string/button_voice" />
|
android:text="@string/button_voice" />
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/devoice"
|
android:id="@+id/devoice"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:text="@string/button_devoice" />
|
android:text="@string/button_devoice" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/kick"
|
android:id="@+id/kick"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:text="@string/button_kick" />
|
android:text="@string/button_kick" />
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/ban"
|
android:id="@+id/ban"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:text="@string/button_ban" />
|
android:text="@string/button_ban" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@ -20,9 +20,9 @@ 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/>.
|
||||||
-->
|
-->
|
||||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/host"
|
android:id="@+id/host"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="7px"
|
android:padding="7px"
|
||||||
android:text=""
|
android:text=""
|
||||||
android:textSize="12px" />
|
android:textSize="12px" />
|
@ -24,10 +24,10 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
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="@android:drawable/ic_menu_add" />
|
||||||
<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/menu_users" />
|
||||||
<item
|
<item
|
||||||
android:id="@+id/close"
|
android:id="@+id/close"
|
||||||
android:title="@string/close"
|
android:title="@string/close"
|
||||||
|
@ -24,16 +24,16 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
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="@android:drawable/ic_menu_add" />
|
||||||
<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="@android:drawable/ic_menu_preferences" />
|
||||||
<item
|
<item
|
||||||
android:id="@+id/about"
|
android:id="@+id/about"
|
||||||
android:title="@string/about_menu"
|
android:title="@string/about_menu"
|
||||||
android:icon="@android:drawable/ic_menu_help" />
|
android:icon="@android:drawable/ic_menu_help" />
|
||||||
<item
|
<item
|
||||||
android:id="@+id/exit"
|
android:id="@+id/exit"
|
||||||
android:title="@string/exit_menu"
|
android:title="@string/exit_menu"
|
||||||
android:icon="@android:drawable/ic_menu_close_clear_cancel" />
|
android:icon="@android:drawable/ic_menu_close_clear_cancel" />
|
||||||
</menu>
|
</menu>
|
@ -7,7 +7,7 @@
|
|||||||
<string name="app_copyright">(C) 2009-2010 Sebastian Kaspari</string>
|
<string name="app_copyright">(C) 2009-2010 Sebastian Kaspari</string>
|
||||||
|
|
||||||
<string name="licence_info">
|
<string name="licence_info">
|
||||||
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 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.
|
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.
|
||||||
</string>
|
</string>
|
||||||
</resources>
|
</resources>
|
@ -1,69 +1,69 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<string-array name="charsets">
|
<string-array name="charsets">
|
||||||
<item name="UTF-8">UTF-8</item>
|
<item name="UTF-8">UTF-8</item>
|
||||||
<item name="Big">Big5</item>
|
<item name="Big">Big5</item>
|
||||||
<item name="BOCU-1">BOCU-1</item>
|
<item name="BOCU-1">BOCU-1</item>
|
||||||
<item name="CESU-8">CESU-8</item>
|
<item name="CESU-8">CESU-8</item>
|
||||||
<item name="cp864">cp864</item>
|
<item name="cp864">cp864</item>
|
||||||
<item name="EUC-JP">EUC-JP</item>
|
<item name="EUC-JP">EUC-JP</item>
|
||||||
<item name="EUC-KR">EUC-KR</item>
|
<item name="EUC-KR">EUC-KR</item>
|
||||||
<item name="GBK">GBK</item>
|
<item name="GBK">GBK</item>
|
||||||
<item name="HZ-GB-2312">HZ-GB-2312</item>
|
<item name="HZ-GB-2312">HZ-GB-2312</item>
|
||||||
<item name="ISO-2022-JP">ISO-2022-JP</item>
|
<item name="ISO-2022-JP">ISO-2022-JP</item>
|
||||||
<item name="ISO-8859-1">ISO-8859-1</item>
|
<item name="ISO-8859-1">ISO-8859-1</item>
|
||||||
<item name="ISO-8859-10">ISO-8859-10</item>
|
<item name="ISO-8859-10">ISO-8859-10</item>
|
||||||
<item name="ISO-8859-13">ISO-8859-13</item>
|
<item name="ISO-8859-13">ISO-8859-13</item>
|
||||||
<item name="ISO-8859-14">ISO-8859-14</item>
|
<item name="ISO-8859-14">ISO-8859-14</item>
|
||||||
<item name="ISO-8859-15">ISO-8859-15</item>
|
<item name="ISO-8859-15">ISO-8859-15</item>
|
||||||
<item name="ISO-8859-16">ISO-8859-16</item>
|
<item name="ISO-8859-16">ISO-8859-16</item>
|
||||||
<item name="ISO-8859-2">ISO-8859-2</item>
|
<item name="ISO-8859-2">ISO-8859-2</item>
|
||||||
<item name="ISO-8859-3">ISO-8859-3</item>
|
<item name="ISO-8859-3">ISO-8859-3</item>
|
||||||
<item name="ISO-8859-4">ISO-8859-4</item>
|
<item name="ISO-8859-4">ISO-8859-4</item>
|
||||||
<item name="ISO-8859-5">ISO-8859-5</item>
|
<item name="ISO-8859-5">ISO-8859-5</item>
|
||||||
<item name="ISO-8859-6">ISO-8859-6</item>
|
<item name="ISO-8859-6">ISO-8859-6</item>
|
||||||
<item name="ISO-8859-7">ISO-8859-7</item>
|
<item name="ISO-8859-7">ISO-8859-7</item>
|
||||||
<item name="ISO-8859-8">ISO-8859-8</item>
|
<item name="ISO-8859-8">ISO-8859-8</item>
|
||||||
<item name="ISO-8859-9">ISO-8859-9</item>
|
<item name="ISO-8859-9">ISO-8859-9</item>
|
||||||
<item name="KOI8-R">KOI8-R</item>
|
<item name="KOI8-R">KOI8-R</item>
|
||||||
<item name="macintosh">macintosh</item>
|
<item name="macintosh">macintosh</item>
|
||||||
<item name="SCSU">SCSU</item>
|
<item name="SCSU">SCSU</item>
|
||||||
<item name="Shift_JIS">Shift_JIS</item>
|
<item name="Shift_JIS">Shift_JIS</item>
|
||||||
<item name="TIS-620">TIS-620</item>
|
<item name="TIS-620">TIS-620</item>
|
||||||
<item name="US-ASCII">US-ASCII</item>
|
<item name="US-ASCII">US-ASCII</item>
|
||||||
<item name="UTF-16">UTF-16</item>
|
<item name="UTF-16">UTF-16</item>
|
||||||
<item name="UTF-16BE">UTF-16BE</item>
|
<item name="UTF-16BE">UTF-16BE</item>
|
||||||
<item name="UTF-16LE">UTF-16LE</item>
|
<item name="UTF-16LE">UTF-16LE</item>
|
||||||
<item name="UTF-32">UTF-32</item>
|
<item name="UTF-32">UTF-32</item>
|
||||||
<item name="UTF-32BE">UTF-32BE</item>
|
<item name="UTF-32BE">UTF-32BE</item>
|
||||||
<item name="UTF-32LE">UTF-32LE</item>
|
<item name="UTF-32LE">UTF-32LE</item>
|
||||||
<item name="UTF-7">UTF-7</item>
|
<item name="UTF-7">UTF-7</item>
|
||||||
<item name="windows-1250">windows-1250</item>
|
<item name="windows-1250">windows-1250</item>
|
||||||
<item name="windows-1251">windows-1251</item>
|
<item name="windows-1251">windows-1251</item>
|
||||||
<item name="windows-1252">windows-1252</item>
|
<item name="windows-1252">windows-1252</item>
|
||||||
<item name="windows-1253">windows-1253</item>
|
<item name="windows-1253">windows-1253</item>
|
||||||
<item name="windows-1254">windows-1254</item>
|
<item name="windows-1254">windows-1254</item>
|
||||||
<item name="windows-1255">windows-1255</item>
|
<item name="windows-1255">windows-1255</item>
|
||||||
<item name="windows-1256">windows-1256</item>
|
<item name="windows-1256">windows-1256</item>
|
||||||
<item name="windows-1257">windows-1257</item>
|
<item name="windows-1257">windows-1257</item>
|
||||||
<item name="windows-1258">windows-1258</item>
|
<item name="windows-1258">windows-1258</item>
|
||||||
<item name="x-docomo-shift_jis-2007">x-docomo-shift_jis-2007</item>
|
<item name="x-docomo-shift_jis-2007">x-docomo-shift_jis-2007</item>
|
||||||
<item name="x-gsm-03.38-2000">x-gsm-03.38-2000</item>
|
<item name="x-gsm-03.38-2000">x-gsm-03.38-2000</item>
|
||||||
<item name="x-ibm-1383_P110-1999">x-ibm-1383_P110-1999</item>
|
<item name="x-ibm-1383_P110-1999">x-ibm-1383_P110-1999</item>
|
||||||
<item name="x-IMAP-mailbox-name">x-IMAP-mailbox-name</item>
|
<item name="x-IMAP-mailbox-name">x-IMAP-mailbox-name</item>
|
||||||
<item name="x-iscii-be">x-iscii-be</item>
|
<item name="x-iscii-be">x-iscii-be</item>
|
||||||
<item name="x-iscii-de">x-iscii-de</item>
|
<item name="x-iscii-de">x-iscii-de</item>
|
||||||
<item name="x-iscii-gu">x-iscii-gu</item>
|
<item name="x-iscii-gu">x-iscii-gu</item>
|
||||||
<item name="x-iscii-ka">x-iscii-ka</item>
|
<item name="x-iscii-ka">x-iscii-ka</item>
|
||||||
<item name="x-iscii-ma">x-iscii-ma</item>
|
<item name="x-iscii-ma">x-iscii-ma</item>
|
||||||
<item name="x-iscii-or">x-iscii-or</item>
|
<item name="x-iscii-or">x-iscii-or</item>
|
||||||
<item name="x-iscii-pa">x-iscii-pa</item>
|
<item name="x-iscii-pa">x-iscii-pa</item>
|
||||||
<item name="x-iscii-ta">x-iscii-ta</item>
|
<item name="x-iscii-ta">x-iscii-ta</item>
|
||||||
<item name="x-iscii-te">x-iscii-te</item>
|
<item name="x-iscii-te">x-iscii-te</item>
|
||||||
<item name="x-iso-8859_11-2001">x-iso-8859_11-2001</item>
|
<item name="x-iso-8859_11-2001">x-iso-8859_11-2001</item>
|
||||||
<item name="x-UTF16_OppositeEndian">x-UTF16_OppositeEndian</item>
|
<item name="x-UTF16_OppositeEndian">x-UTF16_OppositeEndian</item>
|
||||||
<item name="x-UTF16_PlatformEndian">x-UTF16_PlatformEndian</item>
|
<item name="x-UTF16_PlatformEndian">x-UTF16_PlatformEndian</item>
|
||||||
<item name="x-UTF32_OppositeEndian">x-UTF32_OppositeEndian</item>
|
<item name="x-UTF32_OppositeEndian">x-UTF32_OppositeEndian</item>
|
||||||
<item name="x-UTF32_PlatformEndian">x-UTF32_PlatformEndian</item>
|
<item name="x-UTF32_PlatformEndian">x-UTF32_PlatformEndian</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
</resources>
|
</resources>
|
@ -1,32 +1,32 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<string name="key_show_timestamp">show_timestamp</string>
|
<string name="key_show_timestamp">show_timestamp</string>
|
||||||
<string name="default_show_timestamp">false</string>
|
<string name="default_show_timestamp">false</string>
|
||||||
|
|
||||||
<string name="key_show_icons">show_icons</string>
|
<string name="key_show_icons">show_icons</string>
|
||||||
<string name="default_show_icons">true</string>
|
<string name="default_show_icons">true</string>
|
||||||
|
|
||||||
<string name="key_show_colors">show_colors</string>
|
<string name="key_show_colors">show_colors</string>
|
||||||
<string name="default_show_colors">true</string>
|
<string name="default_show_colors">true</string>
|
||||||
|
|
||||||
<string name="key_show_colors_nick">show_colors_nick</string>
|
<string name="key_show_colors_nick">show_colors_nick</string>
|
||||||
<string name="default_show_colors_nick">false</string>
|
<string name="default_show_colors_nick">false</string>
|
||||||
|
|
||||||
<string name="key_24h_format">24h_format</string>
|
<string name="key_24h_format">24h_format</string>
|
||||||
<string name="default_24h_format">true</string>
|
<string name="default_24h_format">true</string>
|
||||||
|
|
||||||
<string name="key_reconnect">reconnect</string>
|
<string name="key_reconnect">reconnect</string>
|
||||||
<string name="default_reconnect">false</string>
|
<string name="default_reconnect">false</string>
|
||||||
|
|
||||||
<string name="key_quitmessage">quitmessage</string>
|
<string name="key_quitmessage">quitmessage</string>
|
||||||
<string name="default_quitmessage">Yaaic - Yet another Android IRC client - http://www.yaaic.org</string>
|
<string name="default_quitmessage">Yaaic - Yet another Android IRC client - http://www.yaaic.org</string>
|
||||||
|
|
||||||
<string name="key_fontsize">fontsize</string>
|
<string name="key_fontsize">fontsize</string>
|
||||||
<string name="default_fontsize">11</string>
|
<string name="default_fontsize">11</string>
|
||||||
|
|
||||||
<string name="key_voice_recognition">voice_recognition</string>
|
<string name="key_voice_recognition">voice_recognition</string>
|
||||||
<string name="default_voice_recognition">false</string>
|
<string name="default_voice_recognition">false</string>
|
||||||
|
|
||||||
<string name="key_vibrate_highlight">vibrate_highlight</string>
|
<string name="key_vibrate_highlight">vibrate_highlight</string>
|
||||||
<string name="default_vibrate_highlight">true</string>
|
<string name="default_vibrate_highlight">true</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -20,18 +20,18 @@ 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/>.
|
||||||
-->
|
-->
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:title="@string/settings_connection">
|
android:title="@string/settings_connection">
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:title="@string/settings_reconnect_title"
|
android:title="@string/settings_reconnect_title"
|
||||||
android:summary="@string/settings_reconnect_desc"
|
android:summary="@string/settings_reconnect_desc"
|
||||||
android:key="@string/key_reconnect"
|
android:key="@string/key_reconnect"
|
||||||
android:defaultValue="@string/default_reconnect" />
|
android:defaultValue="@string/default_reconnect" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:title="@string/settings_chat">
|
android:title="@string/settings_chat">
|
||||||
<ListPreference
|
<ListPreference
|
||||||
android:title="@string/settings_fontsize_title"
|
android:title="@string/settings_fontsize_title"
|
||||||
android:summary="@string/settings_fontsize_desc"
|
android:summary="@string/settings_fontsize_desc"
|
||||||
android:dialogTitle="@string/settings_fontsize_dialog_title"
|
android:dialogTitle="@string/settings_fontsize_dialog_title"
|
||||||
@ -39,52 +39,52 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
android:entryValues="@array/fontsize_values"
|
android:entryValues="@array/fontsize_values"
|
||||||
android:key="@string/key_fontsize"
|
android:key="@string/key_fontsize"
|
||||||
android:defaultValue="@string/default_fontsize" />
|
android:defaultValue="@string/default_fontsize" />
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:title="@string/settings_icons_title"
|
android:title="@string/settings_icons_title"
|
||||||
android:summary="@string/settings_icons_desc"
|
android:summary="@string/settings_icons_desc"
|
||||||
android:key="@string/key_show_icons"
|
android:key="@string/key_show_icons"
|
||||||
android:defaultValue="@string/default_show_icons" />
|
android:defaultValue="@string/default_show_icons" />
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:title="@string/settings_colors_title"
|
android:title="@string/settings_colors_title"
|
||||||
android:summary="@string/settings_colors_desc"
|
android:summary="@string/settings_colors_desc"
|
||||||
android:key="@string/key_show_colors"
|
android:key="@string/key_show_colors"
|
||||||
android:defaultValue="@string/default_show_colors"/>
|
android:defaultValue="@string/default_show_colors"/>
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:title="@string/settings_colors_nick_title"
|
android:title="@string/settings_colors_nick_title"
|
||||||
android:key="@string/key_show_colors_nick"
|
android:key="@string/key_show_colors_nick"
|
||||||
android:summary="@string/settings_colors_nick_desc"
|
android:summary="@string/settings_colors_nick_desc"
|
||||||
android:defaultValue="@string/default_show_colors_nick"/>
|
android:defaultValue="@string/default_show_colors_nick"/>
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:title="@string/settings_timestamp_title"
|
android:title="@string/settings_timestamp_title"
|
||||||
android:summary="@string/settings_timestamp_desc"
|
android:summary="@string/settings_timestamp_desc"
|
||||||
android:key="@string/key_show_timestamp"
|
android:key="@string/key_show_timestamp"
|
||||||
android:defaultValue="@string/default_show_timestamp" />
|
android:defaultValue="@string/default_show_timestamp" />
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:title="@string/settings_24h_title"
|
android:title="@string/settings_24h_title"
|
||||||
android:summary="@string/settings_24h_desc"
|
android:summary="@string/settings_24h_desc"
|
||||||
android:key="@string/key_24h_format"
|
android:key="@string/key_24h_format"
|
||||||
android:defaultValue="@string/default_24h_format"
|
android:defaultValue="@string/default_24h_format"
|
||||||
android:dependency="@string/key_show_timestamp" />
|
android:dependency="@string/key_show_timestamp" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:title="@string/settings_misc">
|
android:title="@string/settings_misc">
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:title="@string/settings_voice_recognition_title"
|
android:title="@string/settings_voice_recognition_title"
|
||||||
android:summary="@string/settings_voice_recognition_desc"
|
android:summary="@string/settings_voice_recognition_desc"
|
||||||
android:key="@string/key_voice_recognition"
|
android:key="@string/key_voice_recognition"
|
||||||
android:defaultValue="@string/default_voice_recognition" />
|
android:defaultValue="@string/default_voice_recognition" />
|
||||||
<EditTextPreference
|
<EditTextPreference
|
||||||
android:title="@string/settings_quitmessage_title"
|
android:title="@string/settings_quitmessage_title"
|
||||||
android:summary="@string/settings_quitmessage_desc"
|
android:summary="@string/settings_quitmessage_desc"
|
||||||
android:key="@string/key_quitmessage"
|
android:key="@string/key_quitmessage"
|
||||||
android:defaultValue="@string/default_quitmessage"
|
android:defaultValue="@string/default_quitmessage"
|
||||||
android:dialogTitle="@string/settings_quitmessage_dialog_title"
|
android:dialogTitle="@string/settings_quitmessage_dialog_title"
|
||||||
android:dialogMessage="@string/settings_quitmessage_dialog_desc" />
|
android:dialogMessage="@string/settings_quitmessage_dialog_desc" />
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:title="@string/settings_vibrate_highlight_title"
|
android:title="@string/settings_vibrate_highlight_title"
|
||||||
android:summary="@string/settings_vibrate_highlight_desc"
|
android:summary="@string/settings_vibrate_highlight_desc"
|
||||||
android:key="@string/key_vibrate_highlight"
|
android:key="@string/key_vibrate_highlight"
|
||||||
android:defaultValue="@string/default_vibrate_highlight" />
|
android:defaultValue="@string/default_vibrate_highlight" />
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
@ -22,9 +22,9 @@ package org.jibble.pircbot;
|
|||||||
* @version 1.4.6 (Build time: Wed Apr 11 19:20:59 2007)
|
* @version 1.4.6 (Build time: Wed Apr 11 19:20:59 2007)
|
||||||
*/
|
*/
|
||||||
public class IrcException extends Exception {
|
public class IrcException extends Exception {
|
||||||
private static final long serialVersionUID = -3705541066912475928L;
|
private static final long serialVersionUID = -3705541066912475928L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new IrcException.
|
* Constructs a new IrcException.
|
||||||
*
|
*
|
||||||
* @param e The error message to report.
|
* @param e The error message to report.
|
||||||
|
@ -25,9 +25,9 @@ package org.jibble.pircbot;
|
|||||||
* @version 1.4.6 (Build time: Wed Apr 11 19:20:59 2007)
|
* @version 1.4.6 (Build time: Wed Apr 11 19:20:59 2007)
|
||||||
*/
|
*/
|
||||||
public class NickAlreadyInUseException extends IrcException {
|
public class NickAlreadyInUseException extends IrcException {
|
||||||
private static final long serialVersionUID = -4724325464519465479L;
|
private static final long serialVersionUID = -4724325464519465479L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new IrcException.
|
* Constructs a new IrcException.
|
||||||
*
|
*
|
||||||
* @param e The error message to report.
|
* @param e The error message to report.
|
||||||
|
@ -158,21 +158,21 @@ public abstract class PircBot implements ReplyConstants {
|
|||||||
// XXX: PircBot Patch for SSL
|
// XXX: PircBot Patch for SSL
|
||||||
Socket socket;
|
Socket socket;
|
||||||
if (_useSSL) {
|
if (_useSSL) {
|
||||||
try {
|
try {
|
||||||
SSLContext context = SSLContext.getInstance("TLS");
|
SSLContext context = SSLContext.getInstance("TLS");
|
||||||
context.init(null, new X509TrustManager[] { new NaiveTrustManager() }, null);
|
context.init(null, new X509TrustManager[] { new NaiveTrustManager() }, null);
|
||||||
SSLSocketFactory factory = context.getSocketFactory();
|
SSLSocketFactory factory = context.getSocketFactory();
|
||||||
SSLSocket ssocket = (SSLSocket) factory.createSocket(hostname, port);
|
SSLSocket ssocket = (SSLSocket) factory.createSocket(hostname, port);
|
||||||
ssocket.startHandshake();
|
ssocket.startHandshake();
|
||||||
socket = ssocket;
|
socket = ssocket;
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
// XXX: It's not really an IOException :)
|
// XXX: It's not really an IOException :)
|
||||||
throw new IOException("Cannot open SSL socket");
|
throw new IOException("Cannot open SSL socket");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
socket = new Socket(hostname, port);
|
socket = new Socket(hostname, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
_inetAddress = socket.getLocalAddress();
|
_inetAddress = socket.getLocalAddress();
|
||||||
@ -245,7 +245,7 @@ public abstract class PircBot implements ReplyConstants {
|
|||||||
|
|
||||||
// XXX: PircBot patch - We are not connected to server if nothing received
|
// XXX: PircBot patch - We are not connected to server if nothing received
|
||||||
if (line == null) {
|
if (line == null) {
|
||||||
throw new IOException("Could not connect to server");
|
throw new IOException("Could not connect to server");
|
||||||
}
|
}
|
||||||
|
|
||||||
// This makes the socket timeout on read operations after 5 minutes.
|
// This makes the socket timeout on read operations after 5 minutes.
|
||||||
@ -293,7 +293,7 @@ public abstract class PircBot implements ReplyConstants {
|
|||||||
*/
|
*/
|
||||||
public void setUseSSL(boolean useSSL)
|
public void setUseSSL(boolean useSSL)
|
||||||
{
|
{
|
||||||
_useSSL = useSSL;
|
_useSSL = useSSL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1014,9 +1014,9 @@ public abstract class PircBot implements ReplyConstants {
|
|||||||
else if (command.equals("QUIT")) {
|
else if (command.equals("QUIT")) {
|
||||||
// Someone has quit from the IRC server.
|
// Someone has quit from the IRC server.
|
||||||
|
|
||||||
// XXX: Pircbot Patch - Call onQuit before removing the user. This way we
|
// XXX: Pircbot Patch - Call onQuit before removing the user. This way we
|
||||||
// are able to know which channels the user was on.
|
// are able to know which channels the user was on.
|
||||||
this.onQuit(sourceNick, sourceLogin, sourceHostname, line.substring(line.indexOf(" :") + 2));
|
this.onQuit(sourceNick, sourceLogin, sourceHostname, line.substring(line.indexOf(" :") + 2));
|
||||||
|
|
||||||
if (sourceNick.equals(this.getNick())) {
|
if (sourceNick.equals(this.getNick())) {
|
||||||
this.removeAllChannels();
|
this.removeAllChannels();
|
||||||
|
@ -36,112 +36,112 @@ import android.content.Context;
|
|||||||
*/
|
*/
|
||||||
public class Yaaic
|
public class Yaaic
|
||||||
{
|
{
|
||||||
public static Yaaic instance;
|
public static Yaaic instance;
|
||||||
|
|
||||||
private HashMap<Integer, Server> servers;
|
private HashMap<Integer, Server> servers;
|
||||||
private boolean serversLoaded = false;
|
private boolean serversLoaded = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private constructor, you may want to use static getInstance()
|
* Private constructor, you may want to use static getInstance()
|
||||||
*/
|
*/
|
||||||
private Yaaic()
|
private Yaaic()
|
||||||
{
|
{
|
||||||
servers = new HashMap<Integer, Server>();
|
servers = new HashMap<Integer, Server>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load servers from database
|
* Load servers from database
|
||||||
*
|
*
|
||||||
* @param context
|
* @param context
|
||||||
*/
|
*/
|
||||||
public void loadServers(Context context)
|
public void loadServers(Context context)
|
||||||
{
|
{
|
||||||
if (!serversLoaded) {
|
if (!serversLoaded) {
|
||||||
Database db = new Database(context);
|
Database db = new Database(context);
|
||||||
servers = db.getServers();
|
servers = db.getServers();
|
||||||
db.close();
|
db.close();
|
||||||
|
|
||||||
//context.sendBroadcast(new Intent(Broadcast.SERVER_UPDATE));
|
//context.sendBroadcast(new Intent(Broadcast.SERVER_UPDATE));
|
||||||
serversLoaded = true;
|
serversLoaded = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get global Yaaic instance
|
* Get global Yaaic instance
|
||||||
*
|
*
|
||||||
* @return the global Yaaic instance
|
* @return the global Yaaic instance
|
||||||
*/
|
*/
|
||||||
public static Yaaic getInstance()
|
public static Yaaic getInstance()
|
||||||
{
|
{
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
instance = new Yaaic();
|
instance = new Yaaic();
|
||||||
}
|
}
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get server by id
|
* Get server by id
|
||||||
*
|
*
|
||||||
* @return Server object with given unique id
|
* @return Server object with given unique id
|
||||||
*/
|
*/
|
||||||
public Server getServerById(int serverId)
|
public Server getServerById(int serverId)
|
||||||
{
|
{
|
||||||
return servers.get(serverId);
|
return servers.get(serverId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove server with given unique id from list
|
* Remove server with given unique id from list
|
||||||
*
|
*
|
||||||
* @param serverId
|
* @param serverId
|
||||||
*/
|
*/
|
||||||
public void removeServerById(int serverId)
|
public void removeServerById(int serverId)
|
||||||
{
|
{
|
||||||
servers.remove(serverId);
|
servers.remove(serverId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set servers
|
* Set servers
|
||||||
*
|
*
|
||||||
* @param servers
|
* @param servers
|
||||||
*/
|
*/
|
||||||
public void setServers(HashMap<Integer, Server> servers)
|
public void setServers(HashMap<Integer, Server> servers)
|
||||||
{
|
{
|
||||||
this.servers = servers;
|
this.servers = servers;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add server to list
|
* Add server to list
|
||||||
*/
|
*/
|
||||||
public void addServer(Server server)
|
public void addServer(Server server)
|
||||||
{
|
{
|
||||||
if (!servers.containsKey(server.getId())) {
|
if (!servers.containsKey(server.getId())) {
|
||||||
servers.put(server.getId(), server);
|
servers.put(server.getId(), server);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update a server in list
|
* Update a server in list
|
||||||
*/
|
*/
|
||||||
public void updateServer(Server server)
|
public void updateServer(Server server)
|
||||||
{
|
{
|
||||||
servers.put(server.getId(), server);
|
servers.put(server.getId(), server);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get list of servers
|
* Get list of servers
|
||||||
*
|
*
|
||||||
* @return list of servers
|
* @return list of servers
|
||||||
*/
|
*/
|
||||||
public ArrayList<Server> getServersAsArrayList()
|
public ArrayList<Server> getServersAsArrayList()
|
||||||
{
|
{
|
||||||
ArrayList<Server> serverList = new ArrayList<Server>();
|
ArrayList<Server> serverList = new ArrayList<Server>();
|
||||||
|
|
||||||
Set<Integer> mKeys = servers.keySet();
|
Set<Integer> mKeys = servers.keySet();
|
||||||
for (int key : mKeys) {
|
for (int key : mKeys) {
|
||||||
serverList.add(servers.get(key));
|
serverList.add(servers.get(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
return serverList;
|
return serverList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,15 +33,15 @@ import android.view.Window;
|
|||||||
*/
|
*/
|
||||||
public class AboutActivity extends Activity
|
public class AboutActivity extends Activity
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* On create
|
* On create
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState)
|
public void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||||
|
|
||||||
setContentView(R.layout.about);
|
setContentView(R.layout.about);
|
||||||
}
|
}
|
||||||
|
@ -24,106 +24,106 @@ import android.widget.AdapterView.OnItemClickListener;
|
|||||||
|
|
||||||
public class AddAliasActivity extends Activity implements OnClickListener, OnItemClickListener, TextWatcher
|
public class AddAliasActivity extends Activity implements OnClickListener, OnItemClickListener, TextWatcher
|
||||||
{
|
{
|
||||||
private EditText aliasInput;
|
private EditText aliasInput;
|
||||||
private ArrayAdapter<String> adapter;
|
private ArrayAdapter<String> adapter;
|
||||||
private ArrayList<String> aliases;
|
private ArrayList<String> aliases;
|
||||||
private Button addButton;
|
private Button addButton;
|
||||||
private Button okButton;
|
private Button okButton;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState)
|
public void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||||
|
|
||||||
setContentView(R.layout.aliasadd);
|
setContentView(R.layout.aliasadd);
|
||||||
|
|
||||||
aliasInput = (EditText) findViewById(R.id.alias);
|
aliasInput = (EditText) findViewById(R.id.alias);
|
||||||
aliasInput.addTextChangedListener(this);
|
aliasInput.addTextChangedListener(this);
|
||||||
|
|
||||||
adapter = new ArrayAdapter<String>(this, R.layout.aliasitem);
|
adapter = new ArrayAdapter<String>(this, R.layout.aliasitem);
|
||||||
|
|
||||||
ListView list = (ListView) findViewById(R.id.aliases);
|
ListView list = (ListView) findViewById(R.id.aliases);
|
||||||
list.setAdapter(adapter);
|
list.setAdapter(adapter);
|
||||||
list.setOnItemClickListener(this);
|
list.setOnItemClickListener(this);
|
||||||
|
|
||||||
addButton = (Button) findViewById(R.id.add);
|
addButton = (Button) findViewById(R.id.add);
|
||||||
addButton.setOnClickListener(this);
|
addButton.setOnClickListener(this);
|
||||||
((Button) findViewById(R.id.cancel)).setOnClickListener(this);
|
((Button) findViewById(R.id.cancel)).setOnClickListener(this);
|
||||||
|
|
||||||
okButton = (Button) findViewById(R.id.ok);
|
okButton = (Button) findViewById(R.id.ok);
|
||||||
okButton.setOnClickListener(this);
|
okButton.setOnClickListener(this);
|
||||||
okButton.setEnabled(false);
|
okButton.setEnabled(false);
|
||||||
|
|
||||||
aliases = getIntent().getExtras().getStringArrayList(Extra.ALIASES);
|
aliases = getIntent().getExtras().getStringArrayList(Extra.ALIASES);
|
||||||
|
|
||||||
for (String alias : aliases) {
|
for (String alias : aliases) {
|
||||||
adapter.add(alias);
|
adapter.add(alias);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On Click
|
* On Click
|
||||||
*/
|
*/
|
||||||
public void onClick(View v)
|
public void onClick(View v)
|
||||||
{
|
{
|
||||||
switch (v.getId()) {
|
switch (v.getId()) {
|
||||||
case R.id.add:
|
case R.id.add:
|
||||||
String alias = aliasInput.getText().toString().trim();
|
String alias = aliasInput.getText().toString().trim();
|
||||||
aliases.add(alias);
|
aliases.add(alias);
|
||||||
adapter.add(alias);
|
adapter.add(alias);
|
||||||
aliasInput.setText("");
|
aliasInput.setText("");
|
||||||
okButton.setEnabled(true);
|
okButton.setEnabled(true);
|
||||||
break;
|
break;
|
||||||
case R.id.cancel:
|
case R.id.cancel:
|
||||||
setResult(RESULT_CANCELED);
|
setResult(RESULT_CANCELED);
|
||||||
finish();
|
finish();
|
||||||
break;
|
break;
|
||||||
case R.id.ok:
|
case R.id.ok:
|
||||||
// Get list and return as result
|
// Get list and return as result
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.putExtra(Extra.ALIASES, aliases);
|
intent.putExtra(Extra.ALIASES, aliases);
|
||||||
setResult(RESULT_OK, intent);
|
setResult(RESULT_OK, intent);
|
||||||
finish();
|
finish();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On item clicked
|
* On item clicked
|
||||||
*/
|
*/
|
||||||
public void onItemClick(AdapterView<?> list, View item, int position, long id)
|
public void onItemClick(AdapterView<?> list, View item, int position, long id)
|
||||||
{
|
{
|
||||||
final String alias = adapter.getItem(position);
|
final String alias = adapter.getItem(position);
|
||||||
|
|
||||||
String[] items = { getResources().getString(R.string.action_remove) };
|
String[] items = { getResources().getString(R.string.action_remove) };
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
builder.setTitle(alias);
|
builder.setTitle(alias);
|
||||||
builder.setItems(items, new DialogInterface.OnClickListener() {
|
builder.setItems(items, new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int item) {
|
public void onClick(DialogInterface dialog, int item) {
|
||||||
switch (item) {
|
switch (item) {
|
||||||
case 0: // Remove
|
case 0: // Remove
|
||||||
adapter.remove(alias);
|
adapter.remove(alias);
|
||||||
aliases.remove(alias);
|
aliases.remove(alias);
|
||||||
okButton.setEnabled(true);
|
okButton.setEnabled(true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
AlertDialog alert = builder.create();
|
AlertDialog alert = builder.create();
|
||||||
alert.show();
|
alert.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void afterTextChanged(Editable s) {
|
public void afterTextChanged(Editable s) {
|
||||||
// Do nothing.
|
// Do nothing.
|
||||||
}
|
}
|
||||||
|
|
||||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||||
// Do nothing.
|
// Do nothing.
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||||
addButton.setEnabled(aliasInput.getText().length() > 0);
|
addButton.setEnabled(aliasInput.getText().length() > 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,94 +47,94 @@ import android.widget.AdapterView.OnItemClickListener;
|
|||||||
*/
|
*/
|
||||||
public class AddChannelActivity extends Activity implements OnClickListener, OnItemClickListener
|
public class AddChannelActivity extends Activity implements OnClickListener, OnItemClickListener
|
||||||
{
|
{
|
||||||
private EditText channelInput;
|
private EditText channelInput;
|
||||||
private ArrayAdapter<String> adapter;
|
private ArrayAdapter<String> adapter;
|
||||||
private ArrayList<String> channels;
|
private ArrayList<String> channels;
|
||||||
private Button okButton;
|
private Button okButton;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On create
|
* On create
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState)
|
public void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||||
|
|
||||||
setContentView(R.layout.channeladd);
|
setContentView(R.layout.channeladd);
|
||||||
|
|
||||||
channelInput = (EditText) findViewById(R.id.channel);
|
channelInput = (EditText) findViewById(R.id.channel);
|
||||||
|
|
||||||
adapter = new ArrayAdapter<String>(this, R.layout.channelitem);
|
adapter = new ArrayAdapter<String>(this, R.layout.channelitem);
|
||||||
|
|
||||||
ListView list = (ListView) findViewById(R.id.channels);
|
ListView list = (ListView) findViewById(R.id.channels);
|
||||||
list.setAdapter(adapter);
|
list.setAdapter(adapter);
|
||||||
list.setOnItemClickListener(this);
|
list.setOnItemClickListener(this);
|
||||||
|
|
||||||
((Button) findViewById(R.id.add)).setOnClickListener(this);
|
((Button) findViewById(R.id.add)).setOnClickListener(this);
|
||||||
((Button) findViewById(R.id.cancel)).setOnClickListener(this);
|
((Button) findViewById(R.id.cancel)).setOnClickListener(this);
|
||||||
|
|
||||||
okButton = (Button) findViewById(R.id.ok);
|
okButton = (Button) findViewById(R.id.ok);
|
||||||
okButton.setOnClickListener(this);
|
okButton.setOnClickListener(this);
|
||||||
okButton.setEnabled(false);
|
okButton.setEnabled(false);
|
||||||
|
|
||||||
channels = getIntent().getExtras().getStringArrayList(Extra.CHANNELS);
|
channels = getIntent().getExtras().getStringArrayList(Extra.CHANNELS);
|
||||||
|
|
||||||
for (String channel : channels) {
|
for (String channel : channels) {
|
||||||
adapter.add(channel);
|
adapter.add(channel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On Click
|
* On Click
|
||||||
*/
|
*/
|
||||||
public void onClick(View v)
|
public void onClick(View v)
|
||||||
{
|
{
|
||||||
switch (v.getId()) {
|
switch (v.getId()) {
|
||||||
case R.id.add:
|
case R.id.add:
|
||||||
String channel = channelInput.getText().toString().trim();
|
String channel = channelInput.getText().toString().trim();
|
||||||
channels.add(channel);
|
channels.add(channel);
|
||||||
adapter.add(channel);
|
adapter.add(channel);
|
||||||
channelInput.setText("#");
|
channelInput.setText("#");
|
||||||
okButton.setEnabled(true);
|
okButton.setEnabled(true);
|
||||||
break;
|
break;
|
||||||
case R.id.cancel:
|
case R.id.cancel:
|
||||||
setResult(RESULT_CANCELED);
|
setResult(RESULT_CANCELED);
|
||||||
finish();
|
finish();
|
||||||
break;
|
break;
|
||||||
case R.id.ok:
|
case R.id.ok:
|
||||||
// Get list and return as result
|
// Get list and return as result
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.putExtra(Extra.CHANNELS, channels);
|
intent.putExtra(Extra.CHANNELS, channels);
|
||||||
setResult(RESULT_OK, intent);
|
setResult(RESULT_OK, intent);
|
||||||
finish();
|
finish();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On item clicked
|
* On item clicked
|
||||||
*/
|
*/
|
||||||
public void onItemClick(AdapterView<?> list, View item, int position, long id)
|
public void onItemClick(AdapterView<?> list, View item, int position, long id)
|
||||||
{
|
{
|
||||||
final String channel = adapter.getItem(position);
|
final String channel = adapter.getItem(position);
|
||||||
|
|
||||||
String[] items = { getResources().getString(R.string.action_remove) };
|
String[] items = { getResources().getString(R.string.action_remove) };
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
builder.setTitle(channel);
|
builder.setTitle(channel);
|
||||||
builder.setItems(items, new DialogInterface.OnClickListener() {
|
builder.setItems(items, new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int item) {
|
public void onClick(DialogInterface dialog, int item) {
|
||||||
switch (item) {
|
switch (item) {
|
||||||
case 0: // Remove
|
case 0: // Remove
|
||||||
adapter.remove(channel);
|
adapter.remove(channel);
|
||||||
channels.remove(channel);
|
channels.remove(channel);
|
||||||
okButton.setEnabled(true);
|
okButton.setEnabled(true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
AlertDialog alert = builder.create();
|
AlertDialog alert = builder.create();
|
||||||
alert.show();
|
alert.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,100 +47,100 @@ import android.widget.AdapterView.OnItemClickListener;
|
|||||||
*/
|
*/
|
||||||
public class AddCommandsActivity extends Activity implements OnClickListener, OnItemClickListener
|
public class AddCommandsActivity extends Activity implements OnClickListener, OnItemClickListener
|
||||||
{
|
{
|
||||||
private EditText commandInput;
|
private EditText commandInput;
|
||||||
private ArrayAdapter<String> adapter;
|
private ArrayAdapter<String> adapter;
|
||||||
private ArrayList<String> commands;
|
private ArrayList<String> commands;
|
||||||
private Button okButton;
|
private Button okButton;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On create
|
* On create
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState)
|
public void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||||
|
|
||||||
setContentView(R.layout.commandadd);
|
setContentView(R.layout.commandadd);
|
||||||
|
|
||||||
commandInput = (EditText) findViewById(R.id.command);
|
commandInput = (EditText) findViewById(R.id.command);
|
||||||
|
|
||||||
adapter = new ArrayAdapter<String>(this, R.layout.commanditem);
|
adapter = new ArrayAdapter<String>(this, R.layout.commanditem);
|
||||||
|
|
||||||
ListView list = (ListView) findViewById(R.id.commands);
|
ListView list = (ListView) findViewById(R.id.commands);
|
||||||
list.setAdapter(adapter);
|
list.setAdapter(adapter);
|
||||||
list.setOnItemClickListener(this);
|
list.setOnItemClickListener(this);
|
||||||
|
|
||||||
((Button) findViewById(R.id.add)).setOnClickListener(this);
|
((Button) findViewById(R.id.add)).setOnClickListener(this);
|
||||||
((Button) findViewById(R.id.ok)).setOnClickListener(this);
|
((Button) findViewById(R.id.ok)).setOnClickListener(this);
|
||||||
((Button) findViewById(R.id.cancel)).setOnClickListener(this);
|
((Button) findViewById(R.id.cancel)).setOnClickListener(this);
|
||||||
|
|
||||||
okButton = (Button) findViewById(R.id.ok);
|
okButton = (Button) findViewById(R.id.ok);
|
||||||
okButton.setOnClickListener(this);
|
okButton.setOnClickListener(this);
|
||||||
okButton.setEnabled(false);
|
okButton.setEnabled(false);
|
||||||
|
|
||||||
commands = getIntent().getExtras().getStringArrayList(Extra.COMMANDS);
|
commands = getIntent().getExtras().getStringArrayList(Extra.COMMANDS);
|
||||||
|
|
||||||
for (String command : commands) {
|
for (String command : commands) {
|
||||||
adapter.add(command);
|
adapter.add(command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On Click
|
* On Click
|
||||||
*/
|
*/
|
||||||
public void onClick(View v)
|
public void onClick(View v)
|
||||||
{
|
{
|
||||||
switch (v.getId()) {
|
switch (v.getId()) {
|
||||||
case R.id.add:
|
case R.id.add:
|
||||||
String command = commandInput.getText().toString().trim();
|
String command = commandInput.getText().toString().trim();
|
||||||
|
|
||||||
if (!command.startsWith("/")) {
|
if (!command.startsWith("/")) {
|
||||||
command = "/" + command;
|
command = "/" + command;
|
||||||
}
|
}
|
||||||
|
|
||||||
commands.add(command);
|
commands.add(command);
|
||||||
adapter.add(command);
|
adapter.add(command);
|
||||||
commandInput.setText("/");
|
commandInput.setText("/");
|
||||||
okButton.setEnabled(true);
|
okButton.setEnabled(true);
|
||||||
break;
|
break;
|
||||||
case R.id.cancel:
|
case R.id.cancel:
|
||||||
setResult(RESULT_CANCELED);
|
setResult(RESULT_CANCELED);
|
||||||
finish();
|
finish();
|
||||||
break;
|
break;
|
||||||
case R.id.ok:
|
case R.id.ok:
|
||||||
// Get list and return as result
|
// Get list and return as result
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.putExtra(Extra.COMMANDS, commands);
|
intent.putExtra(Extra.COMMANDS, commands);
|
||||||
setResult(RESULT_OK, intent);
|
setResult(RESULT_OK, intent);
|
||||||
finish();
|
finish();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On item clicked
|
* On item clicked
|
||||||
*/
|
*/
|
||||||
public void onItemClick(AdapterView<?> list, View item, int position, long id)
|
public void onItemClick(AdapterView<?> list, View item, int position, long id)
|
||||||
{
|
{
|
||||||
final String command = adapter.getItem(position);
|
final String command = adapter.getItem(position);
|
||||||
|
|
||||||
String[] items = { getResources().getString(R.string.action_remove) };
|
String[] items = { getResources().getString(R.string.action_remove) };
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
builder.setTitle(command);
|
builder.setTitle(command);
|
||||||
builder.setItems(items, new DialogInterface.OnClickListener() {
|
builder.setItems(items, new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int item) {
|
public void onClick(DialogInterface dialog, int item) {
|
||||||
switch (item) {
|
switch (item) {
|
||||||
case 0: // Remove
|
case 0: // Remove
|
||||||
adapter.remove(command);
|
adapter.remove(command);
|
||||||
commands.remove(command);
|
commands.remove(command);
|
||||||
okButton.setEnabled(true);
|
okButton.setEnabled(true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
AlertDialog alert = builder.create();
|
AlertDialog alert = builder.create();
|
||||||
alert.show();
|
alert.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,19 +53,19 @@ import org.yaaic.model.Status;
|
|||||||
*/
|
*/
|
||||||
public class AddServerActivity extends Activity implements OnClickListener
|
public class AddServerActivity extends Activity 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;
|
||||||
private static final int REQUEST_CODE_ALIASES = 3;
|
private static final int REQUEST_CODE_ALIASES = 3;
|
||||||
|
|
||||||
private Server server;
|
private Server server;
|
||||||
private ArrayList<String> aliases;
|
private ArrayList<String> aliases;
|
||||||
private ArrayList<String> channels;
|
private ArrayList<String> channels;
|
||||||
private ArrayList<String> commands;
|
private ArrayList<String> commands;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On create
|
* On create
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState)
|
public void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@ -89,327 +89,327 @@ 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)) {
|
||||||
// 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));
|
||||||
aliases.addAll(server.getIdentity().getAliases());
|
aliases.addAll(server.getIdentity().getAliases());
|
||||||
this.channels = db.getChannelsByServerId(server.getId());
|
this.channels = db.getChannelsByServerId(server.getId());
|
||||||
this.commands = db.getCommandsByServerId(server.getId());
|
this.commands = db.getCommandsByServerId(server.getId());
|
||||||
db.close();
|
db.close();
|
||||||
|
|
||||||
// Set server values
|
// Set server values
|
||||||
((EditText) findViewById(R.id.title)).setText(server.getTitle());
|
((EditText) findViewById(R.id.title)).setText(server.getTitle());
|
||||||
((EditText) findViewById(R.id.host)).setText(server.getHost());
|
((EditText) findViewById(R.id.host)).setText(server.getHost());
|
||||||
((EditText) findViewById(R.id.port)).setText(String.valueOf(server.getPort()));
|
((EditText) findViewById(R.id.port)).setText(String.valueOf(server.getPort()));
|
||||||
((EditText) findViewById(R.id.password)).setText(server.getPassword());
|
((EditText) findViewById(R.id.password)).setText(server.getPassword());
|
||||||
|
|
||||||
((EditText) findViewById(R.id.nickname)).setText(server.getIdentity().getNickname());
|
((EditText) findViewById(R.id.nickname)).setText(server.getIdentity().getNickname());
|
||||||
((EditText) findViewById(R.id.ident)).setText(server.getIdentity().getIdent());
|
((EditText) findViewById(R.id.ident)).setText(server.getIdentity().getIdent());
|
||||||
((EditText) findViewById(R.id.realname)).setText(server.getIdentity().getRealName());
|
((EditText) findViewById(R.id.realname)).setText(server.getIdentity().getRealName());
|
||||||
((CheckBox) findViewById(R.id.useSSL)).setChecked(server.useSSL());
|
((CheckBox) findViewById(R.id.useSSL)).setChecked(server.useSSL());
|
||||||
|
|
||||||
// Select charset
|
// Select charset
|
||||||
if (server.getCharset() != null) {
|
if (server.getCharset() != null) {
|
||||||
for (int i = 0; i < charsets.length; i++) {
|
for (int i = 0; i < charsets.length; i++) {
|
||||||
if (server.getCharset().equals(charsets[i])) {
|
if (server.getCharset().equals(charsets[i])) {
|
||||||
spinner.setSelection(i);
|
spinner.setSelection(i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Uri uri = getIntent().getData();
|
Uri uri = getIntent().getData();
|
||||||
if (uri != null && uri.getScheme().equals("irc")) {
|
if (uri != null && uri.getScheme().equals("irc")) {
|
||||||
// handling an irc:// uri
|
// handling an irc:// uri
|
||||||
|
|
||||||
((EditText) findViewById(R.id.host)).setText(uri.getHost());
|
((EditText) findViewById(R.id.host)).setText(uri.getHost());
|
||||||
if (uri.getPort() != -1) {
|
if (uri.getPort() != -1) {
|
||||||
((EditText) findViewById(R.id.port)).setText(String.valueOf(uri.getPort()));
|
((EditText) findViewById(R.id.port)).setText(String.valueOf(uri.getPort()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On activity result
|
* On activity result
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data)
|
protected void onActivityResult(int requestCode, int resultCode, Intent data)
|
||||||
{
|
{
|
||||||
if (resultCode != RESULT_OK) {
|
if (resultCode != RESULT_OK) {
|
||||||
return; // ignore everything else
|
return; // ignore everything else
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (requestCode) {
|
switch (requestCode) {
|
||||||
case REQUEST_CODE_ALIASES:
|
case REQUEST_CODE_ALIASES:
|
||||||
aliases.clear();
|
aliases.clear();
|
||||||
aliases.addAll(data.getExtras().getStringArrayList(Extra.ALIASES));
|
aliases.addAll(data.getExtras().getStringArrayList(Extra.ALIASES));
|
||||||
break;
|
break;
|
||||||
case REQUEST_CODE_CHANNELS:
|
case REQUEST_CODE_CHANNELS:
|
||||||
channels = data.getExtras().getStringArrayList(Extra.CHANNELS);
|
channels = data.getExtras().getStringArrayList(Extra.CHANNELS);
|
||||||
break;
|
break;
|
||||||
case REQUEST_CODE_COMMANDS:
|
case REQUEST_CODE_COMMANDS:
|
||||||
commands = data.getExtras().getStringArrayList(Extra.COMMANDS);
|
commands = data.getExtras().getStringArrayList(Extra.COMMANDS);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On click add server or cancel activity
|
* On click add server or cancel activity
|
||||||
*/
|
*/
|
||||||
public void onClick(View v)
|
public void onClick(View v)
|
||||||
{
|
{
|
||||||
switch (v.getId()) {
|
switch (v.getId()) {
|
||||||
case R.id.aliases:
|
case R.id.aliases:
|
||||||
Intent aliasIntent = new Intent(this, AddAliasActivity.class);
|
Intent aliasIntent = new Intent(this, AddAliasActivity.class);
|
||||||
aliasIntent.putExtra(Extra.ALIASES, aliases);
|
aliasIntent.putExtra(Extra.ALIASES, aliases);
|
||||||
startActivityForResult(aliasIntent, REQUEST_CODE_ALIASES);
|
startActivityForResult(aliasIntent, REQUEST_CODE_ALIASES);
|
||||||
break;
|
break;
|
||||||
case R.id.channels:
|
case R.id.channels:
|
||||||
Intent channelIntent = new Intent(this, AddChannelActivity.class);
|
Intent channelIntent = new Intent(this, AddChannelActivity.class);
|
||||||
channelIntent.putExtra(Extra.CHANNELS, channels);
|
channelIntent.putExtra(Extra.CHANNELS, channels);
|
||||||
startActivityForResult(channelIntent, REQUEST_CODE_CHANNELS);
|
startActivityForResult(channelIntent, REQUEST_CODE_CHANNELS);
|
||||||
break;
|
break;
|
||||||
case R.id.commands:
|
case R.id.commands:
|
||||||
Intent commandsIntent = new Intent(this, AddCommandsActivity.class);
|
Intent commandsIntent = new Intent(this, AddCommandsActivity.class);
|
||||||
commandsIntent.putExtra(Extra.COMMANDS, commands);
|
commandsIntent.putExtra(Extra.COMMANDS, commands);
|
||||||
startActivityForResult(commandsIntent, REQUEST_CODE_COMMANDS);
|
startActivityForResult(commandsIntent, REQUEST_CODE_COMMANDS);
|
||||||
break;
|
break;
|
||||||
case R.id.add:
|
case R.id.add:
|
||||||
try {
|
try {
|
||||||
validateServer();
|
validateServer();
|
||||||
validateIdentity();
|
validateIdentity();
|
||||||
if (server == null) {
|
if (server == null) {
|
||||||
addServer();
|
addServer();
|
||||||
} else {
|
} else {
|
||||||
updateServer();
|
updateServer();
|
||||||
}
|
}
|
||||||
setResult(RESULT_OK);
|
setResult(RESULT_OK);
|
||||||
finish();
|
finish();
|
||||||
} catch(ValidationException e) {
|
} catch(ValidationException e) {
|
||||||
Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case R.id.cancel:
|
case R.id.cancel:
|
||||||
setResult(RESULT_CANCELED);
|
setResult(RESULT_CANCELED);
|
||||||
finish();
|
finish();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add server to database
|
* Add server to database
|
||||||
*/
|
*/
|
||||||
private void addServer()
|
private void addServer()
|
||||||
{
|
{
|
||||||
Database db = new Database(this);
|
Database db = new Database(this);
|
||||||
|
|
||||||
Identity identity = getIdentityFromView();
|
Identity identity = getIdentityFromView();
|
||||||
long identityId = db.addIdentity(
|
long identityId = db.addIdentity(
|
||||||
identity.getNickname(),
|
identity.getNickname(),
|
||||||
identity.getIdent(),
|
identity.getIdent(),
|
||||||
identity.getRealName(),
|
identity.getRealName(),
|
||||||
identity.getAliases()
|
identity.getAliases()
|
||||||
);
|
);
|
||||||
|
|
||||||
Server server = getServerFromView();
|
Server server = getServerFromView();
|
||||||
long serverId = db.addServer(
|
long serverId = db.addServer(
|
||||||
server.getTitle(),
|
server.getTitle(),
|
||||||
server.getHost(),
|
server.getHost(),
|
||||||
server.getPort(),
|
server.getPort(),
|
||||||
server.getPassword(),
|
server.getPassword(),
|
||||||
false, // auto connect
|
false, // auto connect
|
||||||
server.useSSL(),
|
server.useSSL(),
|
||||||
identityId,
|
identityId,
|
||||||
server.getCharset()
|
server.getCharset()
|
||||||
);
|
);
|
||||||
|
|
||||||
db.setChannels((int) serverId, channels);
|
db.setChannels((int) serverId, channels);
|
||||||
db.setCommands((int) serverId, commands);
|
db.setCommands((int) serverId, commands);
|
||||||
|
|
||||||
db.close();
|
db.close();
|
||||||
|
|
||||||
server.setId((int) serverId);
|
server.setId((int) serverId);
|
||||||
server.setIdentity(identity);
|
server.setIdentity(identity);
|
||||||
server.setAutoJoinChannels(channels);
|
server.setAutoJoinChannels(channels);
|
||||||
server.setConnectCommands(commands);
|
server.setConnectCommands(commands);
|
||||||
|
|
||||||
Yaaic.getInstance().addServer(server);
|
Yaaic.getInstance().addServer(server);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update server
|
* Update server
|
||||||
*/
|
*/
|
||||||
private void updateServer()
|
private void updateServer()
|
||||||
{
|
{
|
||||||
Database db = new Database(this);
|
Database db = new Database(this);
|
||||||
|
|
||||||
int serverId = this.server.getId();
|
int serverId = this.server.getId();
|
||||||
int identityId = db.getIdentityIdByServerId(serverId);
|
int identityId = db.getIdentityIdByServerId(serverId);
|
||||||
|
|
||||||
Server server = getServerFromView();
|
Server server = getServerFromView();
|
||||||
db.updateServer(
|
db.updateServer(
|
||||||
serverId,
|
serverId,
|
||||||
server.getTitle(),
|
server.getTitle(),
|
||||||
server.getHost(),
|
server.getHost(),
|
||||||
server.getPort(),
|
server.getPort(),
|
||||||
server.getPassword(),
|
server.getPassword(),
|
||||||
false, // auto connect
|
false, // auto connect
|
||||||
server.useSSL(),
|
server.useSSL(),
|
||||||
identityId,
|
identityId,
|
||||||
server.getCharset()
|
server.getCharset()
|
||||||
);
|
);
|
||||||
|
|
||||||
Identity identity = getIdentityFromView();
|
Identity identity = getIdentityFromView();
|
||||||
db.updateIdentity(
|
db.updateIdentity(
|
||||||
identityId,
|
identityId,
|
||||||
identity.getNickname(),
|
identity.getNickname(),
|
||||||
identity.getIdent(),
|
identity.getIdent(),
|
||||||
identity.getNickname(),
|
identity.getNickname(),
|
||||||
identity.getAliases()
|
identity.getAliases()
|
||||||
);
|
);
|
||||||
|
|
||||||
db.setChannels(serverId, channels);
|
db.setChannels(serverId, channels);
|
||||||
db.setCommands(serverId, commands);
|
db.setCommands(serverId, commands);
|
||||||
|
|
||||||
db.close();
|
db.close();
|
||||||
|
|
||||||
server.setId(this.server.getId());
|
server.setId(this.server.getId());
|
||||||
server.setIdentity(identity);
|
server.setIdentity(identity);
|
||||||
server.setAutoJoinChannels(channels);
|
server.setAutoJoinChannels(channels);
|
||||||
server.setConnectCommands(commands);
|
server.setConnectCommands(commands);
|
||||||
|
|
||||||
Yaaic.getInstance().updateServer(server);
|
Yaaic.getInstance().updateServer(server);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Populate a server object from the data in the view
|
* Populate a server object from the data in the view
|
||||||
*
|
*
|
||||||
* @return The server object
|
* @return The server object
|
||||||
*/
|
*/
|
||||||
private Server getServerFromView()
|
private Server getServerFromView()
|
||||||
{
|
{
|
||||||
String title = ((EditText) findViewById(R.id.title)).getText().toString().trim();
|
String title = ((EditText) findViewById(R.id.title)).getText().toString().trim();
|
||||||
String host = ((EditText) findViewById(R.id.host)).getText().toString().trim();
|
String host = ((EditText) findViewById(R.id.host)).getText().toString().trim();
|
||||||
int port = Integer.parseInt(((EditText) findViewById(R.id.port)).getText().toString().trim());
|
int port = Integer.parseInt(((EditText) findViewById(R.id.port)).getText().toString().trim());
|
||||||
String password = ((EditText) findViewById(R.id.password)).getText().toString().trim();
|
String password = ((EditText) findViewById(R.id.password)).getText().toString().trim();
|
||||||
String charset = ((Spinner) findViewById(R.id.charset)).getSelectedItem().toString();
|
String charset = ((Spinner) findViewById(R.id.charset)).getSelectedItem().toString();
|
||||||
Boolean useSSL = ((CheckBox) findViewById(R.id.useSSL)).isChecked();
|
Boolean useSSL = ((CheckBox) findViewById(R.id.useSSL)).isChecked();
|
||||||
|
|
||||||
// not in use yet
|
// not in use yet
|
||||||
//boolean autoConnect = ((CheckBox) findViewById(R.id.autoconnect)).isChecked();
|
//boolean autoConnect = ((CheckBox) findViewById(R.id.autoconnect)).isChecked();
|
||||||
|
|
||||||
Server server = new Server();
|
Server server = new Server();
|
||||||
server.setHost(host);
|
server.setHost(host);
|
||||||
server.setPort(port);
|
server.setPort(port);
|
||||||
server.setPassword(password);
|
server.setPassword(password);
|
||||||
server.setTitle(title);
|
server.setTitle(title);
|
||||||
server.setCharset(charset);
|
server.setCharset(charset);
|
||||||
server.setUseSSL(useSSL);
|
server.setUseSSL(useSSL);
|
||||||
server.setStatus(Status.DISCONNECTED);
|
server.setStatus(Status.DISCONNECTED);
|
||||||
|
|
||||||
return server;
|
return server;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Populate an identity object from the data in the view
|
* Populate an identity object from the data in the view
|
||||||
*
|
*
|
||||||
* @return The identity object
|
* @return The identity object
|
||||||
*/
|
*/
|
||||||
private Identity getIdentityFromView()
|
private Identity getIdentityFromView()
|
||||||
{
|
{
|
||||||
String nickname = ((EditText) findViewById(R.id.nickname)).getText().toString().trim();
|
String nickname = ((EditText) findViewById(R.id.nickname)).getText().toString().trim();
|
||||||
String ident = ((EditText) findViewById(R.id.ident)).getText().toString().trim();
|
String ident = ((EditText) findViewById(R.id.ident)).getText().toString().trim();
|
||||||
String realname = ((EditText) findViewById(R.id.realname)).getText().toString().trim();
|
String realname = ((EditText) findViewById(R.id.realname)).getText().toString().trim();
|
||||||
|
|
||||||
Identity identity = new Identity();
|
Identity identity = new Identity();
|
||||||
identity.setNickname(nickname);
|
identity.setNickname(nickname);
|
||||||
identity.setIdent(ident);
|
identity.setIdent(ident);
|
||||||
identity.setRealName(realname);
|
identity.setRealName(realname);
|
||||||
|
|
||||||
identity.setAliases(aliases);
|
identity.setAliases(aliases);
|
||||||
|
|
||||||
return identity;
|
return identity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate the input for a server
|
* Validate the input for a server
|
||||||
*
|
*
|
||||||
* @throws ValidationException
|
* @throws ValidationException
|
||||||
*/
|
*/
|
||||||
private void validateServer() throws ValidationException
|
private void validateServer() throws ValidationException
|
||||||
{
|
{
|
||||||
String title = ((EditText) findViewById(R.id.title)).getText().toString();
|
String title = ((EditText) findViewById(R.id.title)).getText().toString();
|
||||||
String host = ((EditText) findViewById(R.id.host)).getText().toString();
|
String host = ((EditText) findViewById(R.id.host)).getText().toString();
|
||||||
String port = ((EditText) findViewById(R.id.port)).getText().toString();
|
String port = ((EditText) findViewById(R.id.port)).getText().toString();
|
||||||
String charset = ((Spinner) findViewById(R.id.charset)).getSelectedItem().toString();
|
String charset = ((Spinner) findViewById(R.id.charset)).getSelectedItem().toString();
|
||||||
|
|
||||||
if (title.trim().equals("")) {
|
if (title.trim().equals("")) {
|
||||||
throw new ValidationException(getResources().getString(R.string.validation_blank_title));
|
throw new ValidationException(getResources().getString(R.string.validation_blank_title));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (host.trim().equals("")) {
|
if (host.trim().equals("")) {
|
||||||
// XXX: We should use some better host validation
|
// XXX: We should use some better host validation
|
||||||
throw new ValidationException(getResources().getString(R.string.validation_blank_host));
|
throw new ValidationException(getResources().getString(R.string.validation_blank_host));
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Integer.parseInt(port);
|
Integer.parseInt(port);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
throw new ValidationException(getResources().getString(R.string.validation_invalid_port));
|
throw new ValidationException(getResources().getString(R.string.validation_invalid_port));
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
"".getBytes(charset);
|
"".getBytes(charset);
|
||||||
}
|
}
|
||||||
catch (UnsupportedEncodingException e) {
|
catch (UnsupportedEncodingException e) {
|
||||||
throw new ValidationException(getResources().getString(R.string.validation_unsupported_charset));
|
throw new ValidationException(getResources().getString(R.string.validation_unsupported_charset));
|
||||||
}
|
}
|
||||||
|
|
||||||
Database db = new Database(this);
|
Database db = new Database(this);
|
||||||
if (db.isTitleUsed(title) && (server == null || !server.getTitle().equals(title))) {
|
if (db.isTitleUsed(title) && (server == null || !server.getTitle().equals(title))) {
|
||||||
db.close();
|
db.close();
|
||||||
throw new ValidationException(getResources().getString(R.string.validation_title_used));
|
throw new ValidationException(getResources().getString(R.string.validation_title_used));
|
||||||
}
|
}
|
||||||
db.close();
|
db.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate the input for a identity
|
* Validate the input for a identity
|
||||||
*
|
*
|
||||||
* @throws ValidationException
|
* @throws ValidationException
|
||||||
*/
|
*/
|
||||||
private void validateIdentity() throws ValidationException
|
private void validateIdentity() throws ValidationException
|
||||||
{
|
{
|
||||||
String nickname = ((EditText) findViewById(R.id.nickname)).getText().toString();
|
String nickname = ((EditText) findViewById(R.id.nickname)).getText().toString();
|
||||||
String ident = ((EditText) findViewById(R.id.ident)).getText().toString();
|
String ident = ((EditText) findViewById(R.id.ident)).getText().toString();
|
||||||
String realname = ((EditText) findViewById(R.id.realname)).getText().toString();
|
String realname = ((EditText) findViewById(R.id.realname)).getText().toString();
|
||||||
|
|
||||||
if (nickname.trim().equals("")) {
|
if (nickname.trim().equals("")) {
|
||||||
throw new ValidationException(getResources().getString(R.string.validation_blank_nickname));
|
throw new ValidationException(getResources().getString(R.string.validation_blank_nickname));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ident.trim().equals("")) {
|
if (ident.trim().equals("")) {
|
||||||
throw new ValidationException(getResources().getString(R.string.validation_blank_ident));
|
throw new ValidationException(getResources().getString(R.string.validation_blank_ident));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (realname.trim().equals("")) {
|
if (realname.trim().equals("")) {
|
||||||
throw new ValidationException(getResources().getString(R.string.validation_blank_realname));
|
throw new ValidationException(getResources().getString(R.string.validation_blank_realname));
|
||||||
}
|
}
|
||||||
|
|
||||||
// RFC 1459: <nick> ::= <letter> { <letter> | <number> | <special> }
|
// RFC 1459: <nick> ::= <letter> { <letter> | <number> | <special> }
|
||||||
// <special> ::= '-' | '[' | ']' | '\' | '`' | '^' | '{' | '}'
|
// <special> ::= '-' | '[' | ']' | '\' | '`' | '^' | '{' | '}'
|
||||||
// Chars that are not in RFC 1459 but are supported too:
|
// Chars that are not in RFC 1459 but are supported too:
|
||||||
// | and _
|
// | and _
|
||||||
Pattern nickPattern = Pattern.compile("^[a-zA-Z_][a-zA-Z0-9^\\-`\\[\\]{}|_\\\\]*$");
|
Pattern nickPattern = Pattern.compile("^[a-zA-Z_][a-zA-Z0-9^\\-`\\[\\]{}|_\\\\]*$");
|
||||||
if (!nickPattern.matcher(nickname).matches()) {
|
if (!nickPattern.matcher(nickname).matches()) {
|
||||||
throw new ValidationException(getResources().getString(R.string.validation_invalid_nickname));
|
throw new ValidationException(getResources().getString(R.string.validation_invalid_nickname));
|
||||||
}
|
}
|
||||||
|
|
||||||
// We currently only allow chars and numbers as ident
|
// We currently only allow chars and numbers as ident
|
||||||
Pattern identPattern = Pattern.compile("^[a-zA-Z0-9]+$");
|
Pattern identPattern = Pattern.compile("^[a-zA-Z0-9]+$");
|
||||||
if (!identPattern.matcher(ident).matches()) {
|
if (!identPattern.matcher(ident).matches()) {
|
||||||
throw new ValidationException(getResources().getString(R.string.validation_invalid_ident));
|
throw new ValidationException(getResources().getString(R.string.validation_invalid_ident));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -38,9 +38,9 @@ import android.widget.EditText;
|
|||||||
*/
|
*/
|
||||||
public class JoinActivity extends Activity implements OnClickListener
|
public class JoinActivity extends Activity implements OnClickListener
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* On create
|
* On create
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState)
|
public void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
@ -54,11 +54,11 @@ public class JoinActivity extends Activity implements OnClickListener
|
|||||||
/**
|
/**
|
||||||
* On click
|
* On click
|
||||||
*/
|
*/
|
||||||
public void onClick(View v)
|
public void onClick(View v)
|
||||||
{
|
{
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.putExtra("channel", ((EditText) findViewById(R.id.channel)).getText().toString());
|
intent.putExtra("channel", ((EditText) findViewById(R.id.channel)).getText().toString());
|
||||||
setResult(RESULT_OK, intent);
|
setResult(RESULT_OK, intent);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,19 +35,19 @@ import android.widget.TextView;
|
|||||||
*/
|
*/
|
||||||
public class MessageActivity extends Activity
|
public class MessageActivity extends Activity
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* On create
|
* On create
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState)
|
public void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||||
setContentView(R.layout.message);
|
setContentView(R.layout.message);
|
||||||
|
|
||||||
((TextView) findViewById(R.id.message)).setText(
|
((TextView) findViewById(R.id.message)).setText(
|
||||||
getIntent().getExtras().getString(Extra.MESSAGE)
|
getIntent().getExtras().getString(Extra.MESSAGE)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,14 +60,14 @@ import org.yaaic.receiver.ServerReceiver;
|
|||||||
* @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 ListActivity implements ServiceConnection, ServerListener, OnItemLongClickListener {
|
||||||
private IRCBinder binder;
|
private IRCBinder binder;
|
||||||
private ServerReceiver receiver;
|
private ServerReceiver receiver;
|
||||||
private ServerListAdapter adapter;
|
private ServerListAdapter adapter;
|
||||||
private ListView list;
|
private ListView list;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On create
|
* On create
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState)
|
public void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
@ -88,7 +88,7 @@ public class ServersActivity extends ListActivity implements ServiceConnection,
|
|||||||
@Override
|
@Override
|
||||||
public void onResume()
|
public void onResume()
|
||||||
{
|
{
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
// Start and connect to service
|
// Start and connect to service
|
||||||
Intent intent = new Intent(this, IRCService.class);
|
Intent intent = new Intent(this, IRCService.class);
|
||||||
@ -96,10 +96,10 @@ public class ServersActivity extends ListActivity implements ServiceConnection,
|
|||||||
startService(intent);
|
startService(intent);
|
||||||
bindService(intent, this, 0);
|
bindService(intent, this, 0);
|
||||||
|
|
||||||
receiver = new ServerReceiver(this);
|
receiver = new ServerReceiver(this);
|
||||||
registerReceiver(receiver, new IntentFilter(Broadcast.SERVER_UPDATE));
|
registerReceiver(receiver, new IntentFilter(Broadcast.SERVER_UPDATE));
|
||||||
|
|
||||||
adapter.loadServers();
|
adapter.loadServers();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -108,210 +108,210 @@ public class ServersActivity extends ListActivity implements ServiceConnection,
|
|||||||
@Override
|
@Override
|
||||||
public void onPause()
|
public void onPause()
|
||||||
{
|
{
|
||||||
super.onPause();
|
super.onPause();
|
||||||
|
|
||||||
if (binder != null && binder.getService() != null) {
|
if (binder != null && binder.getService() != null) {
|
||||||
binder.getService().checkServiceStatus();
|
binder.getService().checkServiceStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
unbindService(this);
|
unbindService(this);
|
||||||
unregisterReceiver(receiver);
|
unregisterReceiver(receiver);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service connected to Activity
|
* Service connected to Activity
|
||||||
*/
|
*/
|
||||||
public void onServiceConnected(ComponentName name, IBinder service)
|
public void onServiceConnected(ComponentName name, IBinder service)
|
||||||
{
|
{
|
||||||
binder = (IRCBinder) service;
|
binder = (IRCBinder) service;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service disconnected from Activity
|
* Service disconnected from Activity
|
||||||
*/
|
*/
|
||||||
public void onServiceDisconnected(ComponentName name)
|
public void onServiceDisconnected(ComponentName name)
|
||||||
{
|
{
|
||||||
binder = null;
|
binder = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On server selected
|
* On server selected
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void onListItemClick(ListView l, View v, int position, long id) {
|
protected void onListItemClick(ListView l, View v, int position, long id) {
|
||||||
Server server = adapter.getItem(position);
|
Server server = adapter.getItem(position);
|
||||||
|
|
||||||
if (server == null) {
|
if (server == null) {
|
||||||
// "Add server" was selected
|
// "Add server" was selected
|
||||||
startActivityForResult(new Intent(this, AddServerActivity.class), 0);
|
startActivityForResult(new Intent(this, AddServerActivity.class), 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Intent intent = new Intent(this, ConversationActivity.class);
|
Intent intent = new Intent(this, ConversationActivity.class);
|
||||||
|
|
||||||
if (server.getStatus() == Status.DISCONNECTED) {
|
if (server.getStatus() == Status.DISCONNECTED) {
|
||||||
server.setStatus(Status.PRE_CONNECTING);
|
server.setStatus(Status.PRE_CONNECTING);
|
||||||
intent.putExtra("connect", true);
|
intent.putExtra("connect", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
intent.putExtra("serverId", server.getId());
|
intent.putExtra("serverId", server.getId());
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On long click
|
* On long click
|
||||||
*/
|
*/
|
||||||
public boolean onItemLongClick(AdapterView<?> l, View v, int position, long id)
|
public boolean onItemLongClick(AdapterView<?> l, View v, int position, long id)
|
||||||
{
|
{
|
||||||
final Server server = adapter.getItem(position);
|
final Server server = adapter.getItem(position);
|
||||||
|
|
||||||
if (server == null) {
|
if (server == null) {
|
||||||
// "Add server" view selected
|
// "Add server" view selected
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
final CharSequence[] items = {
|
final CharSequence[] items = {
|
||||||
getString(R.string.connect),
|
getString(R.string.connect),
|
||||||
getString(R.string.disconnect),
|
getString(R.string.disconnect),
|
||||||
getString(R.string.edit),
|
getString(R.string.edit),
|
||||||
getString(R.string.delete)
|
getString(R.string.delete)
|
||||||
};
|
};
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
builder.setTitle(server.getTitle());
|
builder.setTitle(server.getTitle());
|
||||||
builder.setItems(items, new DialogInterface.OnClickListener() {
|
builder.setItems(items, new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int item) {
|
public void onClick(DialogInterface dialog, int item) {
|
||||||
switch (item) {
|
switch (item) {
|
||||||
case 0: // Connect
|
case 0: // Connect
|
||||||
if (server.getStatus() == Status.DISCONNECTED) {
|
if (server.getStatus() == Status.DISCONNECTED) {
|
||||||
binder.connect(server);
|
binder.connect(server);
|
||||||
server.setStatus(Status.CONNECTING);
|
server.setStatus(Status.CONNECTING);
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 1: // Disconnect
|
case 1: // Disconnect
|
||||||
server.clearConversations();
|
server.clearConversations();
|
||||||
server.setStatus(Status.DISCONNECTED);
|
server.setStatus(Status.DISCONNECTED);
|
||||||
binder.getService().getConnection(server.getId()).quitServer();
|
binder.getService().getConnection(server.getId()).quitServer();
|
||||||
break;
|
break;
|
||||||
case 2: // Edit
|
case 2: // Edit
|
||||||
editServer(server.getId());
|
editServer(server.getId());
|
||||||
break;
|
break;
|
||||||
case 3: // Delete
|
case 3: // Delete
|
||||||
binder.getService().getConnection(server.getId()).quitServer();
|
binder.getService().getConnection(server.getId()).quitServer();
|
||||||
deleteServer(server.getId());
|
deleteServer(server.getId());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
AlertDialog alert = builder.create();
|
AlertDialog alert = builder.create();
|
||||||
alert.show();
|
alert.show();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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)
|
||||||
{
|
{
|
||||||
Server server = Yaaic.getInstance().getServerById(serverId);
|
Server server = Yaaic.getInstance().getServerById(serverId);
|
||||||
|
|
||||||
if (server.getStatus() != Status.DISCONNECTED) {
|
if (server.getStatus() != Status.DISCONNECTED) {
|
||||||
Toast.makeText(this, getResources().getString(R.string.disconnect_before_editing), Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, getResources().getString(R.string.disconnect_before_editing), Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Intent intent = new Intent(this, AddServerActivity.class);
|
Intent intent = new Intent(this, AddServerActivity.class);
|
||||||
intent.putExtra(Extra.SERVER, serverId);
|
intent.putExtra(Extra.SERVER, serverId);
|
||||||
startActivityForResult(intent, 0);
|
startActivityForResult(intent, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Options Menu (Menu Button pressed)
|
* Options Menu (Menu Button pressed)
|
||||||
*/
|
*/
|
||||||
public boolean onCreateOptionsMenu(Menu menu)
|
public boolean onCreateOptionsMenu(Menu menu)
|
||||||
{
|
{
|
||||||
super.onCreateOptionsMenu(menu);
|
super.onCreateOptionsMenu(menu);
|
||||||
|
|
||||||
// inflate from xml
|
// inflate from xml
|
||||||
MenuInflater inflater = getMenuInflater();
|
MenuInflater inflater = getMenuInflater();
|
||||||
inflater.inflate(R.menu.servers, menu);
|
inflater.inflate(R.menu.servers, menu);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On menu item selected
|
* On menu item selected
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean onMenuItemSelected(int featureId, MenuItem item)
|
public boolean onMenuItemSelected(int featureId, MenuItem item)
|
||||||
{
|
{
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.add:
|
case R.id.add:
|
||||||
startActivityForResult(new Intent(this, AddServerActivity.class), 0);
|
startActivityForResult(new Intent(this, AddServerActivity.class), 0);
|
||||||
break;
|
break;
|
||||||
case R.id.about:
|
case R.id.about:
|
||||||
startActivity(new Intent(this, AboutActivity.class));
|
startActivity(new Intent(this, AboutActivity.class));
|
||||||
break;
|
break;
|
||||||
case R.id.settings:
|
case R.id.settings:
|
||||||
startActivity(new Intent(this, SettingsActivity.class));
|
startActivity(new Intent(this, SettingsActivity.class));
|
||||||
break;
|
break;
|
||||||
case R.id.exit:
|
case R.id.exit:
|
||||||
ArrayList<Server> mServers = Yaaic.getInstance().getServersAsArrayList();
|
ArrayList<Server> mServers = Yaaic.getInstance().getServersAsArrayList();
|
||||||
for (Server server : mServers) {
|
for (Server server : mServers) {
|
||||||
if (binder.getService().hasConnection(server.getId())) {
|
if (binder.getService().hasConnection(server.getId())) {
|
||||||
server.setStatus(Status.DISCONNECTED);
|
server.setStatus(Status.DISCONNECTED);
|
||||||
binder.getService().getConnection(server.getId()).quitServer();
|
binder.getService().getConnection(server.getId()).quitServer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ugly
|
// ugly
|
||||||
binder.getService().stopForegroundCompat(R.string.app_name);
|
binder.getService().stopForegroundCompat(R.string.app_name);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On activity result
|
* On activity result
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data)
|
protected void onActivityResult(int requestCode, int resultCode, Intent data)
|
||||||
{
|
{
|
||||||
if (resultCode == RESULT_OK) {
|
if (resultCode == RESULT_OK) {
|
||||||
// Refresh list from database
|
// Refresh list from database
|
||||||
adapter.loadServers();
|
adapter.loadServers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete server
|
* Delete server
|
||||||
*
|
*
|
||||||
* @param serverId
|
* @param serverId
|
||||||
*/
|
*/
|
||||||
public void deleteServer(int serverId)
|
public void deleteServer(int serverId)
|
||||||
{
|
{
|
||||||
Database db = new Database(this);
|
Database db = new Database(this);
|
||||||
db.removeServerById(serverId);
|
db.removeServerById(serverId);
|
||||||
db.close();
|
db.close();
|
||||||
|
|
||||||
Yaaic.getInstance().removeServerById(serverId);
|
Yaaic.getInstance().removeServerById(serverId);
|
||||||
adapter.loadServers();
|
adapter.loadServers();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On server status update
|
* On server status update
|
||||||
*/
|
*/
|
||||||
public void onStatusUpdate()
|
public void onStatusUpdate()
|
||||||
{
|
{
|
||||||
adapter.loadServers();
|
adapter.loadServers();
|
||||||
|
|
||||||
if (adapter.getCount() > 2) {
|
if (adapter.getCount() > 2) {
|
||||||
// Hide background if there are servers in the list
|
// Hide background if there are servers in the list
|
||||||
list.setBackgroundDrawable(null);
|
list.setBackgroundDrawable(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -32,10 +32,10 @@ import android.preference.PreferenceActivity;
|
|||||||
*/
|
*/
|
||||||
public class SettingsActivity extends PreferenceActivity
|
public class SettingsActivity extends PreferenceActivity
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* On create
|
* On create
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState)
|
public void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -41,44 +41,44 @@ import android.widget.TextView;
|
|||||||
*/
|
*/
|
||||||
public class UserActivity extends Activity implements OnClickListener
|
public class UserActivity extends Activity implements OnClickListener
|
||||||
{
|
{
|
||||||
private String nickname;
|
private String nickname;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On create
|
* On create
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState)
|
protected void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||||
|
|
||||||
nickname = getIntent().getStringExtra(Extra.USER);
|
nickname = getIntent().getStringExtra(Extra.USER);
|
||||||
setContentView(R.layout.user);
|
setContentView(R.layout.user);
|
||||||
|
|
||||||
// Use full width
|
// Use full width
|
||||||
LayoutParams params = getWindow().getAttributes();
|
LayoutParams params = getWindow().getAttributes();
|
||||||
params.width = WindowManager.LayoutParams.FILL_PARENT;
|
params.width = WindowManager.LayoutParams.FILL_PARENT;
|
||||||
getWindow().setAttributes(params);
|
getWindow().setAttributes(params);
|
||||||
|
|
||||||
((Button) findViewById(R.id.op)).setOnClickListener(this);
|
((Button) findViewById(R.id.op)).setOnClickListener(this);
|
||||||
((Button) findViewById(R.id.deop)).setOnClickListener(this);
|
((Button) findViewById(R.id.deop)).setOnClickListener(this);
|
||||||
((Button) findViewById(R.id.voice)).setOnClickListener(this);
|
((Button) findViewById(R.id.voice)).setOnClickListener(this);
|
||||||
((Button) findViewById(R.id.devoice)).setOnClickListener(this);
|
((Button) findViewById(R.id.devoice)).setOnClickListener(this);
|
||||||
((Button) findViewById(R.id.kick)).setOnClickListener(this);
|
((Button) findViewById(R.id.kick)).setOnClickListener(this);
|
||||||
((Button) findViewById(R.id.ban)).setOnClickListener(this);
|
((Button) findViewById(R.id.ban)).setOnClickListener(this);
|
||||||
|
|
||||||
((TextView) findViewById(R.id.nickname)).setText(nickname);
|
((TextView) findViewById(R.id.nickname)).setText(nickname);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On button click
|
* On button click
|
||||||
*/
|
*/
|
||||||
public void onClick(View v)
|
public void onClick(View v)
|
||||||
{
|
{
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.putExtra(Extra.ACTION, v.getId());
|
intent.putExtra(Extra.ACTION, v.getId());
|
||||||
intent.putExtra(Extra.USER, nickname);
|
intent.putExtra(Extra.USER, nickname);
|
||||||
setResult(RESULT_OK, intent);
|
setResult(RESULT_OK, intent);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,34 +41,34 @@ import android.widget.ArrayAdapter;
|
|||||||
*/
|
*/
|
||||||
public class UsersActivity extends ListActivity implements OnItemClickListener
|
public class UsersActivity extends ListActivity implements OnItemClickListener
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* On create
|
* On create
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState)
|
public void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||||
|
|
||||||
setContentView(R.layout.users);
|
setContentView(R.layout.users);
|
||||||
|
|
||||||
final String[] users = getIntent().getExtras().getStringArray(Extra.USERS);
|
final String[] users = getIntent().getExtras().getStringArray(Extra.USERS);
|
||||||
getListView().setOnItemClickListener(this);
|
getListView().setOnItemClickListener(this);
|
||||||
|
|
||||||
// Add sorted list of users in own thread to avoid blocking UI
|
// Add sorted list of users in own thread to avoid blocking UI
|
||||||
// TODO: Move to a background task and show loading indicator while sorting
|
// TODO: Move to a background task and show loading indicator while sorting
|
||||||
Arrays.sort(users, String.CASE_INSENSITIVE_ORDER);
|
Arrays.sort(users, String.CASE_INSENSITIVE_ORDER);
|
||||||
getListView().setAdapter(new ArrayAdapter<String>(UsersActivity.this, R.layout.useritem, users));
|
getListView().setAdapter(new ArrayAdapter<String>(UsersActivity.this, R.layout.useritem, users));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On user selected
|
* On user selected
|
||||||
*/
|
*/
|
||||||
public void onItemClick(AdapterView<?> list, View item, int position, long id)
|
public void onItemClick(AdapterView<?> list, View item, int position, long id)
|
||||||
{
|
{
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.putExtra(Extra.USER, (String) getListView().getAdapter().getItem(position));
|
intent.putExtra(Extra.USER, (String) getListView().getAdapter().getItem(position));
|
||||||
setResult(RESULT_OK, intent);
|
setResult(RESULT_OK, intent);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,186 +40,186 @@ import android.widget.ListView;
|
|||||||
*/
|
*/
|
||||||
public class DeckAdapter extends BaseAdapter
|
public class DeckAdapter extends BaseAdapter
|
||||||
{
|
{
|
||||||
private LinkedList<Conversation> conversations;
|
private LinkedList<Conversation> conversations;
|
||||||
private MessageListView currentView;
|
private MessageListView currentView;
|
||||||
private String currentChannel;
|
private String currentChannel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new DeckAdapter instance
|
* Create a new DeckAdapter instance
|
||||||
*/
|
*/
|
||||||
public DeckAdapter()
|
public DeckAdapter()
|
||||||
{
|
{
|
||||||
conversations = new LinkedList<Conversation>();
|
conversations = new LinkedList<Conversation>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear conversations
|
* Clear conversations
|
||||||
*/
|
*/
|
||||||
public void clearConversations()
|
public void clearConversations()
|
||||||
{
|
{
|
||||||
conversations = new LinkedList<Conversation>();
|
conversations = new LinkedList<Conversation>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get number of item
|
* Get number of item
|
||||||
*/
|
*/
|
||||||
public int getCount()
|
public int getCount()
|
||||||
{
|
{
|
||||||
return conversations.size();
|
return conversations.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get item at position
|
* Get item at position
|
||||||
*/
|
*/
|
||||||
public Conversation getItem(int position)
|
public Conversation getItem(int position)
|
||||||
{
|
{
|
||||||
if (position >= 0 && position < conversations.size()) {
|
if (position >= 0 && position < conversations.size()) {
|
||||||
return conversations.get(position);
|
return conversations.get(position);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get id of item at position
|
* Get id of item at position
|
||||||
*/
|
*/
|
||||||
public long getItemId(int position)
|
public long getItemId(int position)
|
||||||
{
|
{
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an item
|
* Add an item
|
||||||
*
|
*
|
||||||
* @param channel Name of the channel
|
* @param channel Name of the channel
|
||||||
* @param view The view object
|
* @param view The view object
|
||||||
*/
|
*/
|
||||||
public void addItem(Conversation conversation)
|
public void addItem(Conversation conversation)
|
||||||
{
|
{
|
||||||
conversations.add(conversation);
|
conversations.add(conversation);
|
||||||
|
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an item by the channel's name
|
* Get an item by the channel's name
|
||||||
*
|
*
|
||||||
* @param channel
|
* @param channel
|
||||||
* @return The item
|
* @return The item
|
||||||
*/
|
*/
|
||||||
public int getPositionByName(String name)
|
public int getPositionByName(String name)
|
||||||
{
|
{
|
||||||
// Optimization - cache field lookups
|
// Optimization - cache field lookups
|
||||||
int mSize = conversations.size();
|
int mSize = conversations.size();
|
||||||
LinkedList<Conversation> mItems = this.conversations;
|
LinkedList<Conversation> mItems = this.conversations;
|
||||||
|
|
||||||
for (int i = 0; i < mSize; i++) {
|
for (int i = 0; i < mSize; i++) {
|
||||||
if (mItems.get(i).getName().equalsIgnoreCase(name)) {
|
if (mItems.get(i).getName().equalsIgnoreCase(name)) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove an item
|
* Remove an item
|
||||||
*
|
*
|
||||||
* @param channel
|
* @param channel
|
||||||
*/
|
*/
|
||||||
public void removeItem(String target)
|
public void removeItem(String target)
|
||||||
{
|
{
|
||||||
int position = getPositionByName(target);
|
int position = getPositionByName(target);
|
||||||
|
|
||||||
if (position != -1) {
|
if (position != -1) {
|
||||||
conversations.remove(position);
|
conversations.remove(position);
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set single channel view
|
* Set single channel view
|
||||||
*
|
*
|
||||||
* @param switched
|
* @param switched
|
||||||
*/
|
*/
|
||||||
public void setSwitched(String channel, MessageListView current)
|
public void setSwitched(String channel, MessageListView current)
|
||||||
{
|
{
|
||||||
currentChannel = channel;
|
currentChannel = channel;
|
||||||
currentView = current;
|
currentView = current;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get single channel view
|
* Get single channel view
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public MessageListView getSwitchedView()
|
public MessageListView getSwitchedView()
|
||||||
{
|
{
|
||||||
return currentView;
|
return currentView;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get name of channel (single channel view)
|
* Get name of channel (single channel view)
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String getSwitchedName()
|
public String getSwitchedName()
|
||||||
{
|
{
|
||||||
return currentChannel;
|
return currentChannel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Has the view been switched to single channel view?
|
* Has the view been switched to single channel view?
|
||||||
*
|
*
|
||||||
* @return view true if view is in single channel view, false otherwise
|
* @return view true if view is in single channel view, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean isSwitched()
|
public boolean isSwitched()
|
||||||
{
|
{
|
||||||
return currentView != null;
|
return currentView != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get view at given position
|
* Get view at given position
|
||||||
*/
|
*/
|
||||||
public View getView(int position, View convertView, ViewGroup parent)
|
public View getView(int position, View convertView, ViewGroup parent)
|
||||||
{
|
{
|
||||||
Conversation conversation = getItem(position);
|
Conversation conversation = getItem(position);
|
||||||
return renderConversation(conversation, parent);
|
return renderConversation(conversation, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render a conversation view (MessageListView)
|
* Render a conversation view (MessageListView)
|
||||||
*
|
*
|
||||||
* @param channel The conversation of the view
|
* @param channel The conversation of the view
|
||||||
* @param parent The parent view (context)
|
* @param parent The parent view (context)
|
||||||
* @return The rendered MessageListView
|
* @return The rendered MessageListView
|
||||||
*/
|
*/
|
||||||
public MessageListView renderConversation(Conversation conversation, ViewGroup parent)
|
public MessageListView renderConversation(Conversation conversation, ViewGroup parent)
|
||||||
{
|
{
|
||||||
MessageListView list = new MessageListView(parent.getContext(), parent);
|
MessageListView list = new MessageListView(parent.getContext(), parent);
|
||||||
list.setOnItemClickListener(MessageClickListener.getInstance());
|
list.setOnItemClickListener(MessageClickListener.getInstance());
|
||||||
|
|
||||||
MessageListAdapter adapter = conversation.getMessageListAdapter();
|
MessageListAdapter adapter = conversation.getMessageListAdapter();
|
||||||
if (adapter == null) {
|
if (adapter == null) {
|
||||||
adapter = new MessageListAdapter(conversation, parent.getContext());
|
adapter = new MessageListAdapter(conversation, parent.getContext());
|
||||||
conversation.setMessageListAdapter(adapter);
|
conversation.setMessageListAdapter(adapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
list.setAdapter(adapter);
|
list.setAdapter(adapter);
|
||||||
|
|
||||||
list.setDivider(null);
|
list.setDivider(null);
|
||||||
list.setLayoutParams(new Gallery.LayoutParams(
|
list.setLayoutParams(new Gallery.LayoutParams(
|
||||||
parent.getWidth() / 100 * 85,
|
parent.getWidth() / 100 * 85,
|
||||||
parent.getHeight()
|
parent.getHeight()
|
||||||
));
|
));
|
||||||
|
|
||||||
list.setBackgroundResource(R.layout.rounded);
|
list.setBackgroundResource(R.layout.rounded);
|
||||||
list.setCacheColorHint(0xee000000);
|
list.setCacheColorHint(0xee000000);
|
||||||
list.setPadding(5, 5, 5, 5);
|
list.setPadding(5, 5, 5, 5);
|
||||||
list.setVerticalFadingEdgeEnabled(false);
|
list.setVerticalFadingEdgeEnabled(false);
|
||||||
list.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_INSET);
|
list.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_INSET);
|
||||||
list.setTranscriptMode(ListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);
|
list.setTranscriptMode(ListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);
|
||||||
list.setSelection(list.getAdapter().getCount() - 1); // scroll to bottom
|
list.setSelection(list.getAdapter().getCount() - 1); // scroll to bottom
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,122 +38,122 @@ import android.widget.TextView;
|
|||||||
*/
|
*/
|
||||||
public class MessageListAdapter extends BaseAdapter
|
public class MessageListAdapter extends BaseAdapter
|
||||||
{
|
{
|
||||||
private LinkedList<TextView> messages;
|
private LinkedList<TextView> messages;
|
||||||
private Context context;
|
private Context context;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new MessageAdapter
|
* Create a new MessageAdapter
|
||||||
*
|
*
|
||||||
* @param channel
|
* @param channel
|
||||||
* @param context
|
* @param context
|
||||||
*/
|
*/
|
||||||
public MessageListAdapter(Conversation conversation, Context context)
|
public MessageListAdapter(Conversation conversation, Context context)
|
||||||
{
|
{
|
||||||
LinkedList<TextView> messages = new LinkedList<TextView>();
|
LinkedList<TextView> messages = new LinkedList<TextView>();
|
||||||
|
|
||||||
// Render channel name as first message in channel
|
// Render channel name as first message in channel
|
||||||
if (conversation.getType() != Conversation.TYPE_SERVER) {
|
if (conversation.getType() != Conversation.TYPE_SERVER) {
|
||||||
Message header = new Message(conversation.getName());
|
Message header = new Message(conversation.getName());
|
||||||
header.setColor(Message.COLOR_RED);
|
header.setColor(Message.COLOR_RED);
|
||||||
messages.add(header.renderTextView(context));
|
messages.add(header.renderTextView(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Optimization - cache field lookups
|
// Optimization - cache field lookups
|
||||||
LinkedList<Message> mHistory = conversation.getHistory();
|
LinkedList<Message> mHistory = conversation.getHistory();
|
||||||
int mSize = mHistory.size();
|
int mSize = mHistory.size();
|
||||||
|
|
||||||
for (int i = 0; i < mSize; i++) {
|
for (int i = 0; i < mSize; i++) {
|
||||||
messages.add(mHistory.get(i).renderTextView(context));
|
messages.add(mHistory.get(i).renderTextView(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX: We don't want to clear the buffer, we want to add only
|
// XXX: We don't want to clear the buffer, we want to add only
|
||||||
// buffered messages that are not already added (history)
|
// buffered messages that are not already added (history)
|
||||||
conversation.clearBuffer();
|
conversation.clearBuffer();
|
||||||
|
|
||||||
this.messages = messages;
|
this.messages = messages;
|
||||||
this.context = context;
|
this.context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a message to the list
|
* Add a message to the list
|
||||||
*
|
*
|
||||||
* @param message
|
* @param message
|
||||||
*/
|
*/
|
||||||
public void addMessage(Message message)
|
public void addMessage(Message message)
|
||||||
{
|
{
|
||||||
messages.add(message.renderTextView(context));
|
messages.add(message.renderTextView(context));
|
||||||
|
|
||||||
if (messages.size() > Conversation.HISTORY_SIZE) {
|
if (messages.size() > Conversation.HISTORY_SIZE) {
|
||||||
messages.remove(0);
|
messages.remove(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a list of messages to the list
|
* Add a list of messages to the list
|
||||||
*
|
*
|
||||||
* @param messages
|
* @param messages
|
||||||
*/
|
*/
|
||||||
public void addBulkMessages(LinkedList<Message> messages)
|
public void addBulkMessages(LinkedList<Message> messages)
|
||||||
{
|
{
|
||||||
LinkedList<TextView> mMessages = this.messages;
|
LinkedList<TextView> mMessages = this.messages;
|
||||||
Context mContext = this.context;
|
Context mContext = this.context;
|
||||||
int mSize = messages.size();
|
int mSize = messages.size();
|
||||||
|
|
||||||
for (int i = mSize - 1; i > -1; i--) {
|
for (int i = mSize - 1; i > -1; i--) {
|
||||||
mMessages.add(messages.get(i).renderTextView(mContext));
|
mMessages.add(messages.get(i).renderTextView(mContext));
|
||||||
|
|
||||||
if (mMessages.size() > Conversation.HISTORY_SIZE) {
|
if (mMessages.size() > Conversation.HISTORY_SIZE) {
|
||||||
mMessages.remove(0);
|
mMessages.remove(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get number of items
|
* Get number of items
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public int getCount()
|
public int getCount()
|
||||||
{
|
{
|
||||||
return messages.size();
|
return messages.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get item at given position
|
* Get item at given position
|
||||||
*
|
*
|
||||||
* @param position
|
* @param position
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public TextView getItem(int position)
|
public TextView getItem(int position)
|
||||||
{
|
{
|
||||||
return messages.get(position);
|
return messages.get(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get id of item at given position
|
* Get id of item at given position
|
||||||
*
|
*
|
||||||
* @param position
|
* @param position
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public long getItemId(int position)
|
public long getItemId(int position)
|
||||||
{
|
{
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get item view for the given position
|
* Get item view for the given position
|
||||||
*
|
*
|
||||||
* @param position
|
* @param position
|
||||||
* @param convertView
|
* @param convertView
|
||||||
* @param parent
|
* @param parent
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public View getView(int position, View convertView, ViewGroup parent)
|
public View getView(int position, View convertView, ViewGroup parent)
|
||||||
{
|
{
|
||||||
return getItem(position);
|
return getItem(position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,95 +41,95 @@ import android.widget.TextView;
|
|||||||
*/
|
*/
|
||||||
public class ServerListAdapter extends BaseAdapter
|
public class ServerListAdapter extends BaseAdapter
|
||||||
{
|
{
|
||||||
private ArrayList<Server> servers;
|
private ArrayList<Server> servers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new adapter for server lists
|
* Create a new adapter for server lists
|
||||||
*/
|
*/
|
||||||
public ServerListAdapter()
|
public ServerListAdapter()
|
||||||
{
|
{
|
||||||
loadServers();
|
loadServers();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load servers from database
|
* Load servers from database
|
||||||
*
|
*
|
||||||
* Delegate call to yaaic instance
|
* Delegate call to yaaic instance
|
||||||
*/
|
*/
|
||||||
public void loadServers()
|
public void loadServers()
|
||||||
{
|
{
|
||||||
servers = Yaaic.getInstance().getServersAsArrayList();
|
servers = Yaaic.getInstance().getServersAsArrayList();
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get number of items
|
* Get number of items
|
||||||
*/
|
*/
|
||||||
public int getCount()
|
public int getCount()
|
||||||
{
|
{
|
||||||
int size = servers.size();
|
int size = servers.size();
|
||||||
|
|
||||||
// Display "Add server" item
|
// Display "Add server" item
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get item at position
|
* Get item at position
|
||||||
*
|
*
|
||||||
* @param position
|
* @param position
|
||||||
*/
|
*/
|
||||||
public Server getItem(int position)
|
public Server getItem(int position)
|
||||||
{
|
{
|
||||||
if (servers.size() == 0) {
|
if (servers.size() == 0) {
|
||||||
return null; // No server object for the "add server" view
|
return null; // No server object for the "add server" view
|
||||||
}
|
}
|
||||||
|
|
||||||
return servers.get(position);
|
return servers.get(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get id of item at position
|
* Get id of item at position
|
||||||
*
|
*
|
||||||
* @param position
|
* @param position
|
||||||
*/
|
*/
|
||||||
public long getItemId(int position)
|
public long getItemId(int position)
|
||||||
{
|
{
|
||||||
if (servers.size() == 0) {
|
if (servers.size() == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return getItem(position).getId();
|
return getItem(position).getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get view for item at given position
|
* Get view for item at given position
|
||||||
*
|
*
|
||||||
* @param position
|
* @param position
|
||||||
* @param convertView
|
* @param convertView
|
||||||
* @param parent
|
* @param parent
|
||||||
*/
|
*/
|
||||||
public View getView(int position, View convertView, ViewGroup parent)
|
public View getView(int position, View convertView, ViewGroup parent)
|
||||||
{
|
{
|
||||||
Server server = getItem(position);
|
Server server = getItem(position);
|
||||||
|
|
||||||
LayoutInflater inflater = (LayoutInflater) parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
LayoutInflater inflater = (LayoutInflater) parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
|
|
||||||
if (server == null) {
|
if (server == null) {
|
||||||
// Return "Add server" view
|
// Return "Add server" view
|
||||||
return inflater.inflate(R.layout.addserveritem, null);
|
return inflater.inflate(R.layout.addserveritem, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
View v = inflater.inflate(R.layout.serveritem, null);
|
View v = inflater.inflate(R.layout.serveritem, null);
|
||||||
|
|
||||||
((TextView) v.findViewById(R.id.title)).setText(server.getTitle());
|
((TextView) v.findViewById(R.id.title)).setText(server.getTitle());
|
||||||
((TextView) v.findViewById(R.id.host)).setText(server.getIdentity().getNickname() + " @ " + server.getHost() + " : " + server.getPort());
|
((TextView) v.findViewById(R.id.host)).setText(server.getIdentity().getNickname() + " @ " + server.getHost() + " : " + server.getPort());
|
||||||
|
|
||||||
((ImageView) v.findViewById(R.id.status)).setImageResource(server.getStatusIcon());
|
((ImageView) v.findViewById(R.id.status)).setImageResource(server.getStatusIcon());
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,57 +34,57 @@ import android.content.Context;
|
|||||||
*/
|
*/
|
||||||
public abstract class BaseHandler
|
public abstract class BaseHandler
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Execute the command
|
* Execute the command
|
||||||
*
|
*
|
||||||
* @param params The params given (0 is the command itself)
|
* @param params The params given (0 is the command itself)
|
||||||
* @param server The server object
|
* @param server The server object
|
||||||
* @param channel The channel object or null if no channel is selected
|
* @param channel The channel object or null if no channel is selected
|
||||||
* @param service The service with all server connections
|
* @param service The service with all server connections
|
||||||
* @throws CommandException if command couldn't be executed
|
* @throws CommandException if command couldn't be executed
|
||||||
*/
|
*/
|
||||||
public abstract void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException;
|
public abstract void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the usage description for this command
|
* Get the usage description for this command
|
||||||
*
|
*
|
||||||
* @return The usage description
|
* @return The usage description
|
||||||
*/
|
*/
|
||||||
public abstract String getUsage();
|
public abstract String getUsage();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the description for this command
|
* Get the description for this command
|
||||||
*
|
*
|
||||||
* @param context The current context. Needed for getting string resources
|
* @param context The current context. Needed for getting string resources
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public abstract String getDescription(Context context);
|
public abstract String getDescription(Context context);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Merge params to a string
|
* Merge params to a string
|
||||||
*
|
*
|
||||||
* @params params The params to merge
|
* @params params The params to merge
|
||||||
*/
|
*/
|
||||||
public static String mergeParams(String[] params)
|
public static String mergeParams(String[] params)
|
||||||
{
|
{
|
||||||
return mergeParams(params, 1);
|
return mergeParams(params, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Merge params to a string
|
* Merge params to a string
|
||||||
*
|
*
|
||||||
* @param params The params to merge
|
* @param params The params to merge
|
||||||
* @param position Start at given param
|
* @param position Start at given param
|
||||||
*/
|
*/
|
||||||
public static String mergeParams(String[] params, int position)
|
public static String mergeParams(String[] params, int position)
|
||||||
{
|
{
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
|
||||||
for (; position < params.length; position++) {
|
for (; position < params.length; position++) {
|
||||||
buffer.append(params[position]);
|
buffer.append(params[position]);
|
||||||
buffer.append(" ");
|
buffer.append(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
return buffer.toString().trim();
|
return buffer.toString().trim();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,175 +62,175 @@ import org.yaaic.model.Server;
|
|||||||
*/
|
*/
|
||||||
public class CommandParser
|
public class CommandParser
|
||||||
{
|
{
|
||||||
private HashMap<String, BaseHandler> commands;
|
private HashMap<String, BaseHandler> commands;
|
||||||
private HashMap<String, String> aliases;
|
private HashMap<String, String> aliases;
|
||||||
private static CommandParser instance;
|
private static CommandParser instance;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new CommandParser instance
|
* Create a new CommandParser instance
|
||||||
*/
|
*/
|
||||||
private CommandParser()
|
private CommandParser()
|
||||||
{
|
{
|
||||||
commands = new HashMap<String, BaseHandler>();
|
commands = new HashMap<String, BaseHandler>();
|
||||||
|
|
||||||
// Commands
|
// Commands
|
||||||
commands.put("nick", new NickHandler());
|
commands.put("nick", new NickHandler());
|
||||||
commands.put("join", new JoinHandler());
|
commands.put("join", new JoinHandler());
|
||||||
commands.put("me", new MeHandler());
|
commands.put("me", new MeHandler());
|
||||||
commands.put("names", new NamesHandler());
|
commands.put("names", new NamesHandler());
|
||||||
commands.put("echo", new EchoHandler());
|
commands.put("echo", new EchoHandler());
|
||||||
commands.put("topic", new TopicHandler());
|
commands.put("topic", new TopicHandler());
|
||||||
commands.put("quit", new QuitHandler());
|
commands.put("quit", new QuitHandler());
|
||||||
commands.put("op", new OpHandler());
|
commands.put("op", new OpHandler());
|
||||||
commands.put("voice", new VoiceHandler());
|
commands.put("voice", new VoiceHandler());
|
||||||
commands.put("deop", new DeopHandler());
|
commands.put("deop", new DeopHandler());
|
||||||
commands.put("devoice", new DevoiceHandler());
|
commands.put("devoice", new DevoiceHandler());
|
||||||
commands.put("kick", new KickHandler());
|
commands.put("kick", new KickHandler());
|
||||||
commands.put("query", new QueryHandler());
|
commands.put("query", new QueryHandler());
|
||||||
commands.put("part", new PartHandler());
|
commands.put("part", new PartHandler());
|
||||||
commands.put("close", new CloseHandler());
|
commands.put("close", new CloseHandler());
|
||||||
commands.put("notice", new NoticeHandler());
|
commands.put("notice", new NoticeHandler());
|
||||||
commands.put("dcc", new DCCHandler());
|
commands.put("dcc", new DCCHandler());
|
||||||
commands.put("mode", new ModeHandler());
|
commands.put("mode", new ModeHandler());
|
||||||
commands.put("help", new HelpHandler());
|
commands.put("help", new HelpHandler());
|
||||||
commands.put("away", new AwayHandler());
|
commands.put("away", new AwayHandler());
|
||||||
commands.put("whois", new WhoisHandler());
|
commands.put("whois", new WhoisHandler());
|
||||||
commands.put("msg", new MsgHandler());
|
commands.put("msg", new MsgHandler());
|
||||||
commands.put("quote", new RawHandler());
|
commands.put("quote", new RawHandler());
|
||||||
commands.put("amsg", new AMsgHandler());
|
commands.put("amsg", new AMsgHandler());
|
||||||
|
|
||||||
aliases = new HashMap<String, String>();
|
aliases = new HashMap<String, String>();
|
||||||
|
|
||||||
// Aliases
|
// Aliases
|
||||||
aliases.put("j","join");
|
aliases.put("j","join");
|
||||||
aliases.put("q", "query");
|
aliases.put("q", "query");
|
||||||
aliases.put("h", "help");
|
aliases.put("h", "help");
|
||||||
aliases.put("raw", "quote");
|
aliases.put("raw", "quote");
|
||||||
aliases.put("w", "whois");
|
aliases.put("w", "whois");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the global CommandParser instance
|
* Get the global CommandParser instance
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static synchronized CommandParser getInstance()
|
public static synchronized CommandParser getInstance()
|
||||||
{
|
{
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
instance = new CommandParser();
|
instance = new CommandParser();
|
||||||
}
|
}
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the commands HashMap
|
* Get the commands HashMap
|
||||||
*
|
*
|
||||||
* @return HashMap - command, commandHandler
|
* @return HashMap - command, commandHandler
|
||||||
*/
|
*/
|
||||||
public HashMap<String, BaseHandler> getCommands()
|
public HashMap<String, BaseHandler> getCommands()
|
||||||
{
|
{
|
||||||
return commands;
|
return commands;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the command aliases HashMap
|
* Get the command aliases HashMap
|
||||||
*
|
*
|
||||||
* @return HashMap - alias, command the alias belogs to
|
* @return HashMap - alias, command the alias belogs to
|
||||||
*/
|
*/
|
||||||
public HashMap<String, String> getAliases()
|
public HashMap<String, String> getAliases()
|
||||||
{
|
{
|
||||||
return aliases;
|
return aliases;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is the given command a valid client command?
|
* Is the given command a valid client command?
|
||||||
*
|
*
|
||||||
* @param command The (client) command to check (/command)
|
* @param command The (client) command to check (/command)
|
||||||
* @return true if the command can be handled by the client, false otherwise
|
* @return true if the command can be handled by the client, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean isClientCommand(String command)
|
public boolean isClientCommand(String command)
|
||||||
{
|
{
|
||||||
return commands.containsKey(command.toLowerCase()) || aliases.containsKey(command.toLowerCase());
|
return commands.containsKey(command.toLowerCase()) || aliases.containsKey(command.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle a client command
|
* Handle a client command
|
||||||
*
|
*
|
||||||
* @param type Type of the command (/type param1 param2 ..)
|
* @param type Type of the command (/type param1 param2 ..)
|
||||||
* @param params The parameters of the command (0 is the command itself)
|
* @param params The parameters of the command (0 is the command itself)
|
||||||
* @param server The current server
|
* @param server The current server
|
||||||
* @param conversation The selected conversation
|
* @param conversation The selected conversation
|
||||||
* @param service The service handling the connections
|
* @param service The service handling the connections
|
||||||
*/
|
*/
|
||||||
public void handleClientCommand(String type, String[] params, Server server, Conversation conversation, IRCService service)
|
public void handleClientCommand(String type, String[] params, Server server, Conversation conversation, IRCService service)
|
||||||
{
|
{
|
||||||
BaseHandler command = null;
|
BaseHandler command = null;
|
||||||
if (commands.containsKey(type.toLowerCase())) {
|
if (commands.containsKey(type.toLowerCase())) {
|
||||||
command = commands.get(type);
|
command = commands.get(type);
|
||||||
} else if (aliases.containsKey(type.toLowerCase())) {
|
} else if (aliases.containsKey(type.toLowerCase())) {
|
||||||
String commandInCommands = aliases.get(type.toLowerCase());
|
String commandInCommands = aliases.get(type.toLowerCase());
|
||||||
command = commands.get(commandInCommands);
|
command = commands.get(commandInCommands);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
command.execute(params, server, conversation, service);
|
command.execute(params, server, conversation, service);
|
||||||
} catch(CommandException e) {
|
} catch(CommandException e) {
|
||||||
// Command could not be executed
|
// Command could not be executed
|
||||||
if (conversation != null) {
|
if (conversation != null) {
|
||||||
Message errorMessage = new Message(type + ": " + e.getMessage());
|
Message errorMessage = new Message(type + ": " + e.getMessage());
|
||||||
errorMessage.setColor(Message.COLOR_RED);
|
errorMessage.setColor(Message.COLOR_RED);
|
||||||
conversation.addMessage(errorMessage);
|
conversation.addMessage(errorMessage);
|
||||||
|
|
||||||
// XXX:I18N - How to get a context here? (command_syntax)
|
// XXX:I18N - How to get a context here? (command_syntax)
|
||||||
Message usageMessage = new Message("Syntax: " + command.getUsage());
|
Message usageMessage = new Message("Syntax: " + command.getUsage());
|
||||||
conversation.addMessage(usageMessage);
|
conversation.addMessage(usageMessage);
|
||||||
|
|
||||||
Intent intent = Broadcast.createConversationIntent(
|
Intent intent = Broadcast.createConversationIntent(
|
||||||
Broadcast.CONVERSATION_MESSAGE,
|
Broadcast.CONVERSATION_MESSAGE,
|
||||||
server.getId(),
|
server.getId(),
|
||||||
conversation.getName()
|
conversation.getName()
|
||||||
);
|
);
|
||||||
|
|
||||||
service.sendBroadcast(intent);
|
service.sendBroadcast(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle a server command
|
* Handle a server command
|
||||||
*
|
*
|
||||||
* @param type Type of the command (/type param1 param2 ..)
|
* @param type Type of the command (/type param1 param2 ..)
|
||||||
* @param params The parameters of the command (0 is the command itself)
|
* @param params The parameters of the command (0 is the command itself)
|
||||||
* @param server The current server
|
* @param server The current server
|
||||||
* @param conversation The selected conversation
|
* @param conversation The selected conversation
|
||||||
* @param service The service handling the connections
|
* @param service The service handling the connections
|
||||||
*/
|
*/
|
||||||
public void handleServerCommand(String type, String[] params, Server server, Conversation conversation, IRCService service)
|
public void handleServerCommand(String type, String[] params, Server server, Conversation conversation, IRCService service)
|
||||||
{
|
{
|
||||||
if (params.length > 1) {
|
if (params.length > 1) {
|
||||||
service.getConnection(server.getId()).sendRawLineViaQueue(
|
service.getConnection(server.getId()).sendRawLineViaQueue(
|
||||||
type.toUpperCase() + " " + BaseHandler.mergeParams(params)
|
type.toUpperCase() + " " + BaseHandler.mergeParams(params)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
service.getConnection(server.getId()).sendRawLineViaQueue(type.toUpperCase());
|
service.getConnection(server.getId()).sendRawLineViaQueue(type.toUpperCase());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse the given line
|
* Parse the given line
|
||||||
*
|
*
|
||||||
* @param line
|
* @param line
|
||||||
*/
|
*/
|
||||||
public void parse(String line, Server server, Conversation conversation, IRCService service)
|
public void parse(String line, Server server, Conversation conversation, IRCService service)
|
||||||
{
|
{
|
||||||
line = line.trim().substring(1); // cut the slash
|
line = line.trim().substring(1); // cut the slash
|
||||||
String[] params = line.split(" ");
|
String[] params = line.split(" ");
|
||||||
String type = params[0];
|
String type = params[0];
|
||||||
|
|
||||||
if (isClientCommand(type)) {
|
if (isClientCommand(type)) {
|
||||||
handleClientCommand(type, params, server, conversation, service);
|
handleClientCommand(type, params, server, conversation, service);
|
||||||
} else {
|
} else {
|
||||||
handleServerCommand(type, params, server, conversation, service);
|
handleServerCommand(type, params, server, conversation, service);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,53 +43,53 @@ import android.content.Intent;
|
|||||||
*/
|
*/
|
||||||
public class AMsgHandler extends BaseHandler
|
public class AMsgHandler extends BaseHandler
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Execute /amsg
|
* Execute /amsg
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
||||||
{
|
{
|
||||||
if (params.length > 1) {
|
if (params.length > 1) {
|
||||||
String text = BaseHandler.mergeParams(params);
|
String text = BaseHandler.mergeParams(params);
|
||||||
|
|
||||||
|
|
||||||
Collection<Conversation> mConversations = server.getConversations();
|
Collection<Conversation> mConversations = server.getConversations();
|
||||||
for (Conversation currentConversation : mConversations) {
|
for (Conversation currentConversation : mConversations) {
|
||||||
if (currentConversation.getType() == Conversation.TYPE_CHANNEL) {
|
if (currentConversation.getType() == Conversation.TYPE_CHANNEL) {
|
||||||
Message message = new Message("<" + service.getConnection(server.getId()).getNick() + "> " + text);
|
Message message = new Message("<" + service.getConnection(server.getId()).getNick() + "> " + text);
|
||||||
currentConversation.addMessage(message);
|
currentConversation.addMessage(message);
|
||||||
|
|
||||||
Intent intent = Broadcast.createConversationIntent(
|
Intent intent = Broadcast.createConversationIntent(
|
||||||
Broadcast.CONVERSATION_MESSAGE,
|
Broadcast.CONVERSATION_MESSAGE,
|
||||||
server.getId(),
|
server.getId(),
|
||||||
currentConversation.getName()
|
currentConversation.getName()
|
||||||
);
|
);
|
||||||
|
|
||||||
service.sendBroadcast(intent);
|
service.sendBroadcast(intent);
|
||||||
|
|
||||||
service.getConnection(server.getId()).sendMessage(currentConversation.getName(), text);
|
service.getConnection(server.getId()).sendMessage(currentConversation.getName(), text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new CommandException(service.getString(R.string.invalid_number_of_params));
|
throw new CommandException(service.getString(R.string.invalid_number_of_params));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Usage of /amsg
|
* Usage of /amsg
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getUsage()
|
public String getUsage()
|
||||||
{
|
{
|
||||||
return "/amsg <message>";
|
return "/amsg <message>";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description of /amsg
|
* Description of /amsg
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getDescription(Context context)
|
public String getDescription(Context context)
|
||||||
{
|
{
|
||||||
return context.getString(R.string.command_desc_amsg);
|
return context.getString(R.string.command_desc_amsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,30 +38,30 @@ import android.content.Context;
|
|||||||
*/
|
*/
|
||||||
public class AwayHandler extends BaseHandler
|
public class AwayHandler extends BaseHandler
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Execute /away
|
* Execute /away
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
||||||
{
|
{
|
||||||
service.getConnection(server.getId()).sendRawLineViaQueue("AWAY " + BaseHandler.mergeParams(params));
|
service.getConnection(server.getId()).sendRawLineViaQueue("AWAY " + BaseHandler.mergeParams(params));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get description of /away
|
* Get description of /away
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getDescription(Context context)
|
public String getDescription(Context context)
|
||||||
{
|
{
|
||||||
return context.getString(R.string.command_desc_away);
|
return context.getString(R.string.command_desc_away);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get usage of /away
|
* Get usage of /away
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getUsage()
|
public String getUsage()
|
||||||
{
|
{
|
||||||
return "/away [<reason>]";
|
return "/away [<reason>]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,48 +40,48 @@ import android.content.Intent;
|
|||||||
*/
|
*/
|
||||||
public class CloseHandler extends BaseHandler
|
public class CloseHandler extends BaseHandler
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Execute /close
|
* Execute /close
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
||||||
{
|
{
|
||||||
if (conversation.getType() == Conversation.TYPE_SERVER) {
|
if (conversation.getType() == Conversation.TYPE_SERVER) {
|
||||||
throw new CommandException(service.getString(R.string.close_server_window));
|
throw new CommandException(service.getString(R.string.close_server_window));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params.length == 1) {
|
if (params.length == 1) {
|
||||||
if (conversation.getType() == Conversation.TYPE_CHANNEL) {
|
if (conversation.getType() == Conversation.TYPE_CHANNEL) {
|
||||||
service.getConnection(server.getId()).partChannel(conversation.getName());
|
service.getConnection(server.getId()).partChannel(conversation.getName());
|
||||||
}
|
}
|
||||||
if (conversation.getType() == Conversation.TYPE_QUERY) {
|
if (conversation.getType() == Conversation.TYPE_QUERY) {
|
||||||
server.removeConversation(conversation.getName());
|
server.removeConversation(conversation.getName());
|
||||||
|
|
||||||
Intent intent = Broadcast.createConversationIntent(
|
Intent intent = Broadcast.createConversationIntent(
|
||||||
Broadcast.CONVERSATION_REMOVE,
|
Broadcast.CONVERSATION_REMOVE,
|
||||||
server.getId(),
|
server.getId(),
|
||||||
conversation.getName()
|
conversation.getName()
|
||||||
);
|
);
|
||||||
service.sendBroadcast(intent);
|
service.sendBroadcast(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Usage of /close
|
* Usage of /close
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getUsage()
|
public String getUsage()
|
||||||
{
|
{
|
||||||
return "/close";
|
return "/close";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description of /close
|
* Description of /close
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getDescription(Context context)
|
public String getDescription(Context context)
|
||||||
{
|
{
|
||||||
return context.getString(R.string.command_desc_close);
|
return context.getString(R.string.command_desc_close);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,50 +42,50 @@ import android.content.Context;
|
|||||||
*/
|
*/
|
||||||
public class DCCHandler extends BaseHandler
|
public class DCCHandler extends BaseHandler
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Execute /dcc
|
* Execute /dcc
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
||||||
{
|
{
|
||||||
if (params.length == 4) {
|
if (params.length == 4) {
|
||||||
if (!params[1].equalsIgnoreCase("SEND")) {
|
if (!params[1].equalsIgnoreCase("SEND")) {
|
||||||
throw new CommandException(service.getString(R.string.dcc_only_send));
|
throw new CommandException(service.getString(R.string.dcc_only_send));
|
||||||
}
|
}
|
||||||
File file = new File(params[3]);
|
File file = new File(params[3]);
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
throw new CommandException(service.getString(R.string.dcc_file_not_found, params[3]));
|
throw new CommandException(service.getString(R.string.dcc_file_not_found, params[3]));
|
||||||
}
|
}
|
||||||
|
|
||||||
service.getConnection(server.getId()).dccSendFile(file, params[2], 60000);
|
service.getConnection(server.getId()).dccSendFile(file, params[2], 60000);
|
||||||
|
|
||||||
Message message = new Message(service.getString(R.string.dcc_waiting_accept, params[2]));
|
Message message = new Message(service.getString(R.string.dcc_waiting_accept, params[2]));
|
||||||
message.setColor(Message.COLOR_GREY);
|
message.setColor(Message.COLOR_GREY);
|
||||||
conversation.addMessage(message);
|
conversation.addMessage(message);
|
||||||
|
|
||||||
service.sendBroadcast(
|
service.sendBroadcast(
|
||||||
Broadcast.createConversationIntent(Broadcast.CONVERSATION_MESSAGE, server.getId(), conversation.getName())
|
Broadcast.createConversationIntent(Broadcast.CONVERSATION_MESSAGE, server.getId(), conversation.getName())
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
throw new CommandException(service.getString(R.string.invalid_number_of_params));
|
throw new CommandException(service.getString(R.string.invalid_number_of_params));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Usage of /dcc
|
* Usage of /dcc
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getUsage()
|
public String getUsage()
|
||||||
{
|
{
|
||||||
return "/dcc SEND <nickname> <file>";
|
return "/dcc SEND <nickname> <file>";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description of /dcc
|
* Description of /dcc
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getDescription(Context context)
|
public String getDescription(Context context)
|
||||||
{
|
{
|
||||||
return context.getString(R.string.command_desc_dcc);
|
return context.getString(R.string.command_desc_dcc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,38 +36,38 @@ import android.content.Context;
|
|||||||
*/
|
*/
|
||||||
public class DeopHandler extends BaseHandler
|
public class DeopHandler extends BaseHandler
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Execute /deop
|
* Execute /deop
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
||||||
{
|
{
|
||||||
if (conversation.getType() != Conversation.TYPE_CHANNEL) {
|
if (conversation.getType() != Conversation.TYPE_CHANNEL) {
|
||||||
throw new CommandException(service.getString(R.string.only_usable_from_channel));
|
throw new CommandException(service.getString(R.string.only_usable_from_channel));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params.length == 2) {
|
if (params.length == 2) {
|
||||||
service.getConnection(server.getId()).deOp(conversation.getName(), params[1]);
|
service.getConnection(server.getId()).deOp(conversation.getName(), params[1]);
|
||||||
} else {
|
} else {
|
||||||
throw new CommandException(service.getString(R.string.invalid_number_of_params));
|
throw new CommandException(service.getString(R.string.invalid_number_of_params));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Usage of /deop
|
* Usage of /deop
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getUsage()
|
public String getUsage()
|
||||||
{
|
{
|
||||||
return "/deop <nickname>";
|
return "/deop <nickname>";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description of /deop
|
* Description of /deop
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getDescription(Context context)
|
public String getDescription(Context context)
|
||||||
{
|
{
|
||||||
return context.getString(R.string.command_desc_deop);
|
return context.getString(R.string.command_desc_deop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,38 +36,38 @@ import android.content.Context;
|
|||||||
*/
|
*/
|
||||||
public class DevoiceHandler extends BaseHandler
|
public class DevoiceHandler extends BaseHandler
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Execute /devoice
|
* Execute /devoice
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
||||||
{
|
{
|
||||||
if (conversation.getType() != Conversation.TYPE_CHANNEL) {
|
if (conversation.getType() != Conversation.TYPE_CHANNEL) {
|
||||||
throw new CommandException(service.getString(R.string.only_usable_from_channel));
|
throw new CommandException(service.getString(R.string.only_usable_from_channel));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params.length == 2) {
|
if (params.length == 2) {
|
||||||
service.getConnection(server.getId()).deVoice(conversation.getName(), params[1]);
|
service.getConnection(server.getId()).deVoice(conversation.getName(), params[1]);
|
||||||
} else {
|
} else {
|
||||||
throw new CommandException(service.getString(R.string.invalid_number_of_params));
|
throw new CommandException(service.getString(R.string.invalid_number_of_params));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Usage of /devoice
|
* Usage of /devoice
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getUsage()
|
public String getUsage()
|
||||||
{
|
{
|
||||||
return "/devoice <nickname>";
|
return "/devoice <nickname>";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description of /devoice
|
* Description of /devoice
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getDescription(Context context)
|
public String getDescription(Context context)
|
||||||
{
|
{
|
||||||
return context.getString(R.string.command_desc_devoice);
|
return context.getString(R.string.command_desc_devoice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,42 +39,42 @@ import android.content.Intent;
|
|||||||
*/
|
*/
|
||||||
public class EchoHandler extends BaseHandler
|
public class EchoHandler extends BaseHandler
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Execute /echo
|
* Execute /echo
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
||||||
{
|
{
|
||||||
if (params.length > 1) {
|
if (params.length > 1) {
|
||||||
Message message = new Message(BaseHandler.mergeParams(params));
|
Message message = new Message(BaseHandler.mergeParams(params));
|
||||||
conversation.addMessage(message);
|
conversation.addMessage(message);
|
||||||
|
|
||||||
Intent intent = Broadcast.createConversationIntent(
|
Intent intent = Broadcast.createConversationIntent(
|
||||||
Broadcast.CONVERSATION_MESSAGE,
|
Broadcast.CONVERSATION_MESSAGE,
|
||||||
server.getId(),
|
server.getId(),
|
||||||
conversation.getName()
|
conversation.getName()
|
||||||
);
|
);
|
||||||
service.sendBroadcast(intent);
|
service.sendBroadcast(intent);
|
||||||
} else {
|
} else {
|
||||||
throw new CommandException(service.getString(R.string.text_missing));
|
throw new CommandException(service.getString(R.string.text_missing));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Usage of /echo
|
* Usage of /echo
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getUsage()
|
public String getUsage()
|
||||||
{
|
{
|
||||||
return "/echo <text>";
|
return "/echo <text>";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description of /echo
|
* Description of /echo
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getDescription(Context context)
|
public String getDescription(Context context)
|
||||||
{
|
{
|
||||||
return context.getString(R.string.command_desc_echo);
|
return context.getString(R.string.command_desc_echo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,112 +44,112 @@ import android.content.Intent;
|
|||||||
*/
|
*/
|
||||||
public class HelpHandler extends BaseHandler
|
public class HelpHandler extends BaseHandler
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Execute /help
|
* Execute /help
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
||||||
{
|
{
|
||||||
if (params.length == 2) {
|
if (params.length == 2) {
|
||||||
showCommandDetails(service, server, conversation, params[1]);
|
showCommandDetails(service, server, conversation, params[1]);
|
||||||
} else if (params.length == 1) {
|
} else if (params.length == 1) {
|
||||||
showAllCommands(service, server, conversation);
|
showAllCommands(service, server, conversation);
|
||||||
} else {
|
} else {
|
||||||
throw new CommandException(service.getString(R.string.invalid_number_of_params));
|
throw new CommandException(service.getString(R.string.invalid_number_of_params));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show all available commands
|
* Show all available commands
|
||||||
*
|
*
|
||||||
* @param conversation
|
* @param conversation
|
||||||
* @param server
|
* @param server
|
||||||
* @param service
|
* @param service
|
||||||
*/
|
*/
|
||||||
private void showAllCommands(IRCService service, Server server, Conversation conversation)
|
private void showAllCommands(IRCService service, Server server, Conversation conversation)
|
||||||
{
|
{
|
||||||
CommandParser cp = CommandParser.getInstance();
|
CommandParser cp = CommandParser.getInstance();
|
||||||
|
|
||||||
StringBuffer commandList = new StringBuffer(service.getString(R.string.available_commands));
|
StringBuffer commandList = new StringBuffer(service.getString(R.string.available_commands));
|
||||||
commandList.append("\n");
|
commandList.append("\n");
|
||||||
|
|
||||||
HashMap<String, BaseHandler> commands = cp.getCommands();
|
HashMap<String, BaseHandler> commands = cp.getCommands();
|
||||||
HashMap<String, String> aliases = cp.getAliases();
|
HashMap<String, String> aliases = cp.getAliases();
|
||||||
|
|
||||||
Set<String> commandKeys = commands.keySet();
|
Set<String> commandKeys = commands.keySet();
|
||||||
Set<String> aliasesKeys = aliases.keySet();
|
Set<String> aliasesKeys = aliases.keySet();
|
||||||
|
|
||||||
for (Object command : commandKeys) {
|
for (Object command : commandKeys) {
|
||||||
String alias = "";
|
String alias = "";
|
||||||
for (Object aliasCommand : aliasesKeys) {
|
for (Object aliasCommand : aliasesKeys) {
|
||||||
if (command.equals(aliases.get(aliasCommand))) {
|
if (command.equals(aliases.get(aliasCommand))) {
|
||||||
alias = " " + service.getString(R.string.logical_or) + " /" + aliasCommand;
|
alias = " " + service.getString(R.string.logical_or) + " /" + aliasCommand;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
commandList.append("/" + command.toString() + alias + " - "+commands.get(command).getDescription(service) + "\n");
|
commandList.append("/" + command.toString() + alias + " - "+commands.get(command).getDescription(service) + "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
Message message = new Message(commandList.toString());
|
Message message = new Message(commandList.toString());
|
||||||
message.setColor(Message.COLOR_YELLOW);
|
message.setColor(Message.COLOR_YELLOW);
|
||||||
conversation.addMessage(message);
|
conversation.addMessage(message);
|
||||||
|
|
||||||
Intent intent = Broadcast.createConversationIntent(
|
Intent intent = Broadcast.createConversationIntent(
|
||||||
Broadcast.CONVERSATION_MESSAGE,
|
Broadcast.CONVERSATION_MESSAGE,
|
||||||
server.getId(),
|
server.getId(),
|
||||||
conversation.getName()
|
conversation.getName()
|
||||||
);
|
);
|
||||||
|
|
||||||
service.sendBroadcast(intent);
|
service.sendBroadcast(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show details of a single command
|
* Show details of a single command
|
||||||
*
|
*
|
||||||
* @param conversation
|
* @param conversation
|
||||||
* @param server
|
* @param server
|
||||||
* @param service
|
* @param service
|
||||||
* @param command
|
* @param command
|
||||||
* @throws CommandException
|
* @throws CommandException
|
||||||
*/
|
*/
|
||||||
private void showCommandDetails(IRCService service, Server server, Conversation conversation, String command) throws CommandException
|
private void showCommandDetails(IRCService service, Server server, Conversation conversation, String command) throws CommandException
|
||||||
{
|
{
|
||||||
CommandParser cp = CommandParser.getInstance();
|
CommandParser cp = CommandParser.getInstance();
|
||||||
HashMap<String, BaseHandler> commands = cp.getCommands();
|
HashMap<String, BaseHandler> commands = cp.getCommands();
|
||||||
|
|
||||||
if (commands.containsKey(command)) {
|
if (commands.containsKey(command)) {
|
||||||
// XXX:I18N - String building salad :)
|
// 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 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.COLOR_YELLOW);
|
||||||
conversation.addMessage(message);
|
conversation.addMessage(message);
|
||||||
|
|
||||||
Intent intent = Broadcast.createConversationIntent(
|
Intent intent = Broadcast.createConversationIntent(
|
||||||
Broadcast.CONVERSATION_MESSAGE,
|
Broadcast.CONVERSATION_MESSAGE,
|
||||||
server.getId(),
|
server.getId(),
|
||||||
conversation.getName()
|
conversation.getName()
|
||||||
);
|
);
|
||||||
|
|
||||||
service.sendBroadcast(intent);
|
service.sendBroadcast(intent);
|
||||||
} else {
|
} else {
|
||||||
throw new CommandException(service.getString(R.string.unknown_command, command));
|
throw new CommandException(service.getString(R.string.unknown_command, command));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Usage of /help
|
* Usage of /help
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getUsage()
|
public String getUsage()
|
||||||
{
|
{
|
||||||
return "/help [<command>]";
|
return "/help [<command>]";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description of /help
|
* Description of /help
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getDescription(Context context)
|
public String getDescription(Context context)
|
||||||
{
|
{
|
||||||
return context.getString(R.string.command_desc_help);
|
return context.getString(R.string.command_desc_help);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,36 +36,36 @@ import android.content.Context;
|
|||||||
*/
|
*/
|
||||||
public class JoinHandler extends BaseHandler
|
public class JoinHandler extends BaseHandler
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Execute /join
|
* Execute /join
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
||||||
{
|
{
|
||||||
if (params.length == 2) {
|
if (params.length == 2) {
|
||||||
service.getConnection(server.getId()).joinChannel(params[1]);
|
service.getConnection(server.getId()).joinChannel(params[1]);
|
||||||
} else if (params.length == 3) {
|
} else if (params.length == 3) {
|
||||||
service.getConnection(server.getId()).joinChannel(params[1], params[2]);
|
service.getConnection(server.getId()).joinChannel(params[1], params[2]);
|
||||||
} else {
|
} else {
|
||||||
throw new CommandException(service.getString(R.string.invalid_number_of_params));
|
throw new CommandException(service.getString(R.string.invalid_number_of_params));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Usage of /join
|
* Usage of /join
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getUsage()
|
public String getUsage()
|
||||||
{
|
{
|
||||||
return "/join <channel> [<key>]";
|
return "/join <channel> [<key>]";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description of /join
|
* Description of /join
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getDescription(Context context)
|
public String getDescription(Context context)
|
||||||
{
|
{
|
||||||
return context.getString(R.string.command_desc_join);
|
return context.getString(R.string.command_desc_join);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,38 +38,38 @@ import android.content.Context;
|
|||||||
*/
|
*/
|
||||||
public class KickHandler extends BaseHandler
|
public class KickHandler extends BaseHandler
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Execute /kick
|
* Execute /kick
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
||||||
{
|
{
|
||||||
if (conversation.getType() != Conversation.TYPE_CHANNEL) {
|
if (conversation.getType() != Conversation.TYPE_CHANNEL) {
|
||||||
throw new CommandException(service.getString(R.string.only_usable_from_channel));
|
throw new CommandException(service.getString(R.string.only_usable_from_channel));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params.length == 2) {
|
if (params.length == 2) {
|
||||||
service.getConnection(server.getId()).kick(conversation.getName(), params[1]);
|
service.getConnection(server.getId()).kick(conversation.getName(), params[1]);
|
||||||
} else {
|
} else {
|
||||||
throw new CommandException(service.getString(R.string.invalid_number_of_params));
|
throw new CommandException(service.getString(R.string.invalid_number_of_params));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Usage of /kick
|
* Usage of /kick
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getUsage()
|
public String getUsage()
|
||||||
{
|
{
|
||||||
return "/kick <nickname>";
|
return "/kick <nickname>";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description of /kick
|
* Description of /kick
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getDescription(Context context)
|
public String getDescription(Context context)
|
||||||
{
|
{
|
||||||
return context.getString(R.string.command_desc_kick);
|
return context.getString(R.string.command_desc_kick);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,52 +39,52 @@ import android.content.Intent;
|
|||||||
*/
|
*/
|
||||||
public class MeHandler extends BaseHandler
|
public class MeHandler extends BaseHandler
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Execute /me
|
* Execute /me
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
||||||
{
|
{
|
||||||
if (conversation.getType() == Conversation.TYPE_SERVER) {
|
if (conversation.getType() == Conversation.TYPE_SERVER) {
|
||||||
throw new CommandException(service.getString(R.string.only_usable_from_channel_or_query));
|
throw new CommandException(service.getString(R.string.only_usable_from_channel_or_query));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params.length > 1) {
|
if (params.length > 1) {
|
||||||
String action = BaseHandler.mergeParams(params);
|
String action = BaseHandler.mergeParams(params);
|
||||||
String nickname = service.getConnection(server.getId()).getNick();
|
String nickname = service.getConnection(server.getId()).getNick();
|
||||||
|
|
||||||
Message message = new Message(nickname + " " + action);
|
Message message = new Message(nickname + " " + action);
|
||||||
message.setIcon(R.drawable.action);
|
message.setIcon(R.drawable.action);
|
||||||
server.getConversation(conversation.getName()).addMessage(message);
|
server.getConversation(conversation.getName()).addMessage(message);
|
||||||
|
|
||||||
Intent intent = Broadcast.createConversationIntent(
|
Intent intent = Broadcast.createConversationIntent(
|
||||||
Broadcast.CONVERSATION_MESSAGE,
|
Broadcast.CONVERSATION_MESSAGE,
|
||||||
server.getId(),
|
server.getId(),
|
||||||
conversation.getName()
|
conversation.getName()
|
||||||
);
|
);
|
||||||
service.sendBroadcast(intent);
|
service.sendBroadcast(intent);
|
||||||
|
|
||||||
service.getConnection(server.getId()).sendAction(conversation.getName(), action);
|
service.getConnection(server.getId()).sendAction(conversation.getName(), action);
|
||||||
} else {
|
} else {
|
||||||
throw new CommandException(service.getString(R.string.text_missing));
|
throw new CommandException(service.getString(R.string.text_missing));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Usage of /me
|
* Usage of /me
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getUsage()
|
public String getUsage()
|
||||||
{
|
{
|
||||||
return "/me <text>";
|
return "/me <text>";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description of /me
|
* Description of /me
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getDescription(Context context)
|
public String getDescription(Context context)
|
||||||
{
|
{
|
||||||
return context.getString(R.string.command_desc_me);
|
return context.getString(R.string.command_desc_me);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,36 +38,36 @@ import android.content.Context;
|
|||||||
*/
|
*/
|
||||||
public class ModeHandler extends BaseHandler
|
public class ModeHandler extends BaseHandler
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Execute /mode
|
* Execute /mode
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
||||||
{
|
{
|
||||||
if (params.length > 2) {
|
if (params.length > 2) {
|
||||||
String modes = BaseHandler.mergeParams(params, 2);
|
String modes = BaseHandler.mergeParams(params, 2);
|
||||||
|
|
||||||
service.getConnection(server.getId()).setMode(params[1], modes);
|
service.getConnection(server.getId()).setMode(params[1], modes);
|
||||||
} else {
|
} else {
|
||||||
throw new CommandException(service.getString(R.string.invalid_number_of_params));
|
throw new CommandException(service.getString(R.string.invalid_number_of_params));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Usage of /mode
|
* Usage of /mode
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getUsage()
|
public String getUsage()
|
||||||
{
|
{
|
||||||
return "/mode <channel> <mode>";
|
return "/mode <channel> <mode>";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description of /mode
|
* Description of /mode
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getDescription(Context context)
|
public String getDescription(Context context)
|
||||||
{
|
{
|
||||||
return context.getString(R.string.command_desc_mode);
|
return context.getString(R.string.command_desc_mode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,50 +41,50 @@ import android.content.Intent;
|
|||||||
*/
|
*/
|
||||||
public class MsgHandler extends BaseHandler
|
public class MsgHandler extends BaseHandler
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Execute /msg
|
* Execute /msg
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
||||||
{
|
{
|
||||||
if (params.length > 2) {
|
if (params.length > 2) {
|
||||||
String text = BaseHandler.mergeParams(params, 2);
|
String text = BaseHandler.mergeParams(params, 2);
|
||||||
service.getConnection(server.getId()).sendMessage(params[1], text);
|
service.getConnection(server.getId()).sendMessage(params[1], text);
|
||||||
|
|
||||||
Conversation targetConversation = server.getConversation(params[1]);
|
Conversation targetConversation = server.getConversation(params[1]);
|
||||||
|
|
||||||
if (targetConversation != null) {
|
if (targetConversation != null) {
|
||||||
Message message = new Message("<" + service.getConnection(server.getId()).getNick() + "> " + text);
|
Message message = new Message("<" + service.getConnection(server.getId()).getNick() + "> " + text);
|
||||||
targetConversation.addMessage(message);
|
targetConversation.addMessage(message);
|
||||||
|
|
||||||
Intent intent = Broadcast.createConversationIntent(
|
Intent intent = Broadcast.createConversationIntent(
|
||||||
Broadcast.CONVERSATION_MESSAGE,
|
Broadcast.CONVERSATION_MESSAGE,
|
||||||
server.getId(),
|
server.getId(),
|
||||||
targetConversation.getName()
|
targetConversation.getName()
|
||||||
);
|
);
|
||||||
|
|
||||||
service.sendBroadcast(intent);
|
service.sendBroadcast(intent);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new CommandException(service.getString(R.string.invalid_number_of_params));
|
throw new CommandException(service.getString(R.string.invalid_number_of_params));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Usage of /msg
|
* Usage of /msg
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getUsage()
|
public String getUsage()
|
||||||
{
|
{
|
||||||
return "/msg <target> <message>";
|
return "/msg <target> <message>";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description of /msg
|
* Description of /msg
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getDescription(Context context)
|
public String getDescription(Context context)
|
||||||
{
|
{
|
||||||
return context.getString(R.string.command_desc_msg);
|
return context.getString(R.string.command_desc_msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,53 +41,53 @@ import android.content.Intent;
|
|||||||
*/
|
*/
|
||||||
public class NamesHandler extends BaseHandler
|
public class NamesHandler extends BaseHandler
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Execute /names
|
* Execute /names
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
||||||
{
|
{
|
||||||
if (conversation.getType() != Conversation.TYPE_CHANNEL) {
|
if (conversation.getType() != Conversation.TYPE_CHANNEL) {
|
||||||
throw new CommandException(service.getString(R.string.only_usable_from_channel));
|
throw new CommandException(service.getString(R.string.only_usable_from_channel));
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuffer userList = new StringBuffer(service.getString(R.string.message_users_on_chan, conversation.getName()));
|
StringBuffer userList = new StringBuffer(service.getString(R.string.message_users_on_chan, conversation.getName()));
|
||||||
|
|
||||||
User[] mUsers = service.getConnection(server.getId()).getUsers(conversation.getName());
|
User[] mUsers = service.getConnection(server.getId()).getUsers(conversation.getName());
|
||||||
int mSize = mUsers.length;
|
int mSize = mUsers.length;
|
||||||
for (int i = 0; i < mSize; i++) {
|
for (int i = 0; i < mSize; i++) {
|
||||||
userList.append(" ");
|
userList.append(" ");
|
||||||
userList.append(mUsers[i].getPrefix());
|
userList.append(mUsers[i].getPrefix());
|
||||||
userList.append(mUsers[i].getNick());
|
userList.append(mUsers[i].getNick());
|
||||||
}
|
}
|
||||||
|
|
||||||
Message message = new Message(userList.toString());
|
Message message = new Message(userList.toString());
|
||||||
message.setColor(Message.COLOR_YELLOW);
|
message.setColor(Message.COLOR_YELLOW);
|
||||||
conversation.addMessage(message);
|
conversation.addMessage(message);
|
||||||
|
|
||||||
Intent intent = Broadcast.createConversationIntent(
|
Intent intent = Broadcast.createConversationIntent(
|
||||||
Broadcast.CONVERSATION_MESSAGE,
|
Broadcast.CONVERSATION_MESSAGE,
|
||||||
server.getId(),
|
server.getId(),
|
||||||
conversation.getName()
|
conversation.getName()
|
||||||
);
|
);
|
||||||
service.sendBroadcast(intent);
|
service.sendBroadcast(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Usage of /names
|
* Usage of /names
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getUsage()
|
public String getUsage()
|
||||||
{
|
{
|
||||||
return "/names";
|
return "/names";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description of /names
|
* Description of /names
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getDescription(Context context)
|
public String getDescription(Context context)
|
||||||
{
|
{
|
||||||
return context.getString(R.string.command_desc_names);
|
return context.getString(R.string.command_desc_names);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,34 +36,34 @@ import android.content.Context;
|
|||||||
*/
|
*/
|
||||||
public class NickHandler extends BaseHandler
|
public class NickHandler extends BaseHandler
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Execute /nick
|
* Execute /nick
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
||||||
{
|
{
|
||||||
if (params.length == 2) {
|
if (params.length == 2) {
|
||||||
service.getConnection(server.getId()).changeNick(params[1]);
|
service.getConnection(server.getId()).changeNick(params[1]);
|
||||||
} else {
|
} else {
|
||||||
throw new CommandException(service.getString(R.string.invalid_number_of_params));
|
throw new CommandException(service.getString(R.string.invalid_number_of_params));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Usage of /nick
|
* Usage of /nick
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getUsage()
|
public String getUsage()
|
||||||
{
|
{
|
||||||
return "/nick <nickname>";
|
return "/nick <nickname>";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description of /nick
|
* Description of /nick
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getDescription(Context context)
|
public String getDescription(Context context)
|
||||||
{
|
{
|
||||||
return context.getString(R.string.command_desc_nick);
|
return context.getString(R.string.command_desc_nick);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,47 +41,47 @@ import android.content.Intent;
|
|||||||
*/
|
*/
|
||||||
public class NoticeHandler extends BaseHandler
|
public class NoticeHandler extends BaseHandler
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Execute /notice
|
* Execute /notice
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
||||||
{
|
{
|
||||||
if (params.length > 2) {
|
if (params.length > 2) {
|
||||||
String text = BaseHandler.mergeParams(params);
|
String text = BaseHandler.mergeParams(params);
|
||||||
|
|
||||||
Message message = new Message(">" + params[1] + "< " + text);
|
Message message = new Message(">" + params[1] + "< " + text);
|
||||||
message.setIcon(R.drawable.info);
|
message.setIcon(R.drawable.info);
|
||||||
conversation.addMessage(message);
|
conversation.addMessage(message);
|
||||||
|
|
||||||
Intent intent = Broadcast.createConversationIntent(
|
Intent intent = Broadcast.createConversationIntent(
|
||||||
Broadcast.CONVERSATION_MESSAGE,
|
Broadcast.CONVERSATION_MESSAGE,
|
||||||
server.getId(),
|
server.getId(),
|
||||||
conversation.getName()
|
conversation.getName()
|
||||||
);
|
);
|
||||||
service.sendBroadcast(intent);
|
service.sendBroadcast(intent);
|
||||||
|
|
||||||
service.getConnection(server.getId()).sendNotice(params[1], text);
|
service.getConnection(server.getId()).sendNotice(params[1], text);
|
||||||
} else {
|
} else {
|
||||||
throw new CommandException(service.getString(R.string.invalid_number_of_params));
|
throw new CommandException(service.getString(R.string.invalid_number_of_params));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Usage of /notice
|
* Usage of /notice
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getUsage()
|
public String getUsage()
|
||||||
{
|
{
|
||||||
return "/notice <nickname> <message>";
|
return "/notice <nickname> <message>";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description of /notice
|
* Description of /notice
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getDescription(Context context)
|
public String getDescription(Context context)
|
||||||
{
|
{
|
||||||
return context.getString(R.string.command_desc_notice);
|
return context.getString(R.string.command_desc_notice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,38 +36,38 @@ import android.content.Context;
|
|||||||
*/
|
*/
|
||||||
public class OpHandler extends BaseHandler
|
public class OpHandler extends BaseHandler
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Execute /deop
|
* Execute /deop
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
||||||
{
|
{
|
||||||
if (conversation.getType() != Conversation.TYPE_CHANNEL) {
|
if (conversation.getType() != Conversation.TYPE_CHANNEL) {
|
||||||
throw new CommandException(service.getString(R.string.only_usable_from_channel));
|
throw new CommandException(service.getString(R.string.only_usable_from_channel));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params.length == 2) {
|
if (params.length == 2) {
|
||||||
service.getConnection(server.getId()).op(conversation.getName(), params[1]);
|
service.getConnection(server.getId()).op(conversation.getName(), params[1]);
|
||||||
} else {
|
} else {
|
||||||
throw new CommandException(service.getString(R.string.invalid_number_of_params));
|
throw new CommandException(service.getString(R.string.invalid_number_of_params));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Usage of /deop
|
* Usage of /deop
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getUsage()
|
public String getUsage()
|
||||||
{
|
{
|
||||||
return "/op <nickname>";
|
return "/op <nickname>";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description of /deop
|
* Description of /deop
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getDescription(Context context)
|
public String getDescription(Context context)
|
||||||
{
|
{
|
||||||
return context.getString(R.string.command_desc_op);
|
return context.getString(R.string.command_desc_op);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,40 +38,40 @@ import android.content.Context;
|
|||||||
*/
|
*/
|
||||||
public class PartHandler extends BaseHandler
|
public class PartHandler extends BaseHandler
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Execute /part
|
* Execute /part
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
||||||
{
|
{
|
||||||
if (params.length == 1) {
|
if (params.length == 1) {
|
||||||
if (conversation.getType() != Conversation.TYPE_CHANNEL) {
|
if (conversation.getType() != Conversation.TYPE_CHANNEL) {
|
||||||
throw new CommandException(service.getString(R.string.only_usable_from_channel));
|
throw new CommandException(service.getString(R.string.only_usable_from_channel));
|
||||||
}
|
}
|
||||||
|
|
||||||
service.getConnection(server.getId()).partChannel(conversation.getName());
|
service.getConnection(server.getId()).partChannel(conversation.getName());
|
||||||
} else if (params.length == 2) {
|
} else if (params.length == 2) {
|
||||||
service.getConnection(server.getId()).partChannel(params[1]);
|
service.getConnection(server.getId()).partChannel(params[1]);
|
||||||
} else {
|
} else {
|
||||||
throw new CommandException(service.getString(R.string.invalid_number_of_params));
|
throw new CommandException(service.getString(R.string.invalid_number_of_params));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Usage of /part
|
* Usage of /part
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getUsage()
|
public String getUsage()
|
||||||
{
|
{
|
||||||
return "/part [<channel>]";
|
return "/part [<channel>]";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description of /part
|
* Description of /part
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getDescription(Context context)
|
public String getDescription(Context context)
|
||||||
{
|
{
|
||||||
return context.getString(R.string.command_desc_part);
|
return context.getString(R.string.command_desc_part);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,53 +41,53 @@ import android.content.Intent;
|
|||||||
*/
|
*/
|
||||||
public class QueryHandler extends BaseHandler
|
public class QueryHandler extends BaseHandler
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Execute /query
|
* Execute /query
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
||||||
{
|
{
|
||||||
if (params.length == 2) {
|
if (params.length == 2) {
|
||||||
// Simple validation
|
// Simple validation
|
||||||
if (params[1].startsWith("#")) {
|
if (params[1].startsWith("#")) {
|
||||||
throw new CommandException(service.getString(R.string.query_to_channel));
|
throw new CommandException(service.getString(R.string.query_to_channel));
|
||||||
}
|
}
|
||||||
|
|
||||||
Conversation query = server.getConversation(params[1]);
|
Conversation query = server.getConversation(params[1]);
|
||||||
|
|
||||||
if (query != null) {
|
if (query != null) {
|
||||||
throw new CommandException(service.getString(R.string.query_exists));
|
throw new CommandException(service.getString(R.string.query_exists));
|
||||||
}
|
}
|
||||||
|
|
||||||
query = new Query(params[1]);
|
query = new Query(params[1]);
|
||||||
server.addConversationl(query);
|
server.addConversationl(query);
|
||||||
|
|
||||||
Intent intent = Broadcast.createConversationIntent(
|
Intent intent = Broadcast.createConversationIntent(
|
||||||
Broadcast.CONVERSATION_NEW,
|
Broadcast.CONVERSATION_NEW,
|
||||||
server.getId(),
|
server.getId(),
|
||||||
query.getName()
|
query.getName()
|
||||||
);
|
);
|
||||||
service.sendBroadcast(intent);
|
service.sendBroadcast(intent);
|
||||||
} else {
|
} else {
|
||||||
throw new CommandException(service.getString(R.string.invalid_number_of_params));
|
throw new CommandException(service.getString(R.string.invalid_number_of_params));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Usage of /query
|
* Usage of /query
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getUsage()
|
public String getUsage()
|
||||||
{
|
{
|
||||||
return "/query <nickname>";
|
return "/query <nickname>";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description of /query
|
* Description of /query
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getDescription(Context context)
|
public String getDescription(Context context)
|
||||||
{
|
{
|
||||||
return context.getString(R.string.command_desc_query);
|
return context.getString(R.string.command_desc_query);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,34 +36,34 @@ import android.content.Context;
|
|||||||
*/
|
*/
|
||||||
public class QuitHandler extends BaseHandler
|
public class QuitHandler extends BaseHandler
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Execute /quit
|
* Execute /quit
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
||||||
{
|
{
|
||||||
if (params.length == 1) {
|
if (params.length == 1) {
|
||||||
service.getConnection(server.getId()).quitServer();
|
service.getConnection(server.getId()).quitServer();
|
||||||
} else {
|
} else {
|
||||||
service.getConnection(server.getId()).quitServer(BaseHandler.mergeParams(params));
|
service.getConnection(server.getId()).quitServer(BaseHandler.mergeParams(params));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Usage of /quit
|
* Usage of /quit
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getUsage()
|
public String getUsage()
|
||||||
{
|
{
|
||||||
return "/quit [<reason>]";
|
return "/quit [<reason>]";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description of /quit
|
* Description of /quit
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getDescription(Context context)
|
public String getDescription(Context context)
|
||||||
{
|
{
|
||||||
return context.getString(R.string.command_desc_quit);
|
return context.getString(R.string.command_desc_quit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,35 +38,35 @@ import android.content.Context;
|
|||||||
*/
|
*/
|
||||||
public class RawHandler extends BaseHandler
|
public class RawHandler extends BaseHandler
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Execute /raw
|
* Execute /raw
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
||||||
{
|
{
|
||||||
if (params.length > 1) {
|
if (params.length > 1) {
|
||||||
String line = BaseHandler.mergeParams(params);
|
String line = BaseHandler.mergeParams(params);
|
||||||
service.getConnection(server.getId()).sendRawLineViaQueue(line);
|
service.getConnection(server.getId()).sendRawLineViaQueue(line);
|
||||||
} else {
|
} else {
|
||||||
throw new CommandException(service.getString(R.string.line_missing));
|
throw new CommandException(service.getString(R.string.line_missing));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Usage of /raw
|
* Usage of /raw
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getUsage()
|
public String getUsage()
|
||||||
{
|
{
|
||||||
return "/raw <line>";
|
return "/raw <line>";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description of /raw
|
* Description of /raw
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getDescription(Context context)
|
public String getDescription(Context context)
|
||||||
{
|
{
|
||||||
return context.getString(R.string.command_desc_raw);
|
return context.getString(R.string.command_desc_raw);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,42 +39,42 @@ import android.content.Context;
|
|||||||
*/
|
*/
|
||||||
public class TopicHandler extends BaseHandler
|
public class TopicHandler extends BaseHandler
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Execute /topic
|
* Execute /topic
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
||||||
{
|
{
|
||||||
if (conversation.getType() != Conversation.TYPE_CHANNEL) {
|
if (conversation.getType() != Conversation.TYPE_CHANNEL) {
|
||||||
throw new CommandException(service.getString(R.string.only_usable_from_channel));
|
throw new CommandException(service.getString(R.string.only_usable_from_channel));
|
||||||
}
|
}
|
||||||
|
|
||||||
Channel channel = (Channel) conversation;
|
Channel channel = (Channel) conversation;
|
||||||
|
|
||||||
if (params.length == 1) {
|
if (params.length == 1) {
|
||||||
// Show topic
|
// Show topic
|
||||||
service.getConnection(server.getId()).onTopic(channel.getName(), channel.getTopic(), "", 0, false);
|
service.getConnection(server.getId()).onTopic(channel.getName(), channel.getTopic(), "", 0, false);
|
||||||
} else if (params.length > 1) {
|
} else if (params.length > 1) {
|
||||||
// Change topic
|
// Change topic
|
||||||
service.getConnection(server.getId()).setTopic(channel.getName(), BaseHandler.mergeParams(params));
|
service.getConnection(server.getId()).setTopic(channel.getName(), BaseHandler.mergeParams(params));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Usage of /topic
|
* Usage of /topic
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getUsage()
|
public String getUsage()
|
||||||
{
|
{
|
||||||
return "/topic [<topic>]";
|
return "/topic [<topic>]";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description of /topic
|
* Description of /topic
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getDescription(Context context)
|
public String getDescription(Context context)
|
||||||
{
|
{
|
||||||
return context.getString(R.string.command_desc_topic);
|
return context.getString(R.string.command_desc_topic);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,38 +36,38 @@ import android.content.Context;
|
|||||||
*/
|
*/
|
||||||
public class VoiceHandler extends BaseHandler
|
public class VoiceHandler extends BaseHandler
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Execute /voice
|
* Execute /voice
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
||||||
{
|
{
|
||||||
if (conversation.getType() != Conversation.TYPE_CHANNEL) {
|
if (conversation.getType() != Conversation.TYPE_CHANNEL) {
|
||||||
throw new CommandException(service.getString(R.string.only_usable_from_channel));
|
throw new CommandException(service.getString(R.string.only_usable_from_channel));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params.length == 2) {
|
if (params.length == 2) {
|
||||||
service.getConnection(server.getId()).voice(conversation.getName(), params[1]);
|
service.getConnection(server.getId()).voice(conversation.getName(), params[1]);
|
||||||
} else {
|
} else {
|
||||||
throw new CommandException(service.getString(R.string.invalid_number_of_params));
|
throw new CommandException(service.getString(R.string.invalid_number_of_params));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Usage of /voice
|
* Usage of /voice
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getUsage()
|
public String getUsage()
|
||||||
{
|
{
|
||||||
return "/voice <nickname>";
|
return "/voice <nickname>";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description of /voice
|
* Description of /voice
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getDescription(Context context)
|
public String getDescription(Context context)
|
||||||
{
|
{
|
||||||
return context.getString(R.string.command_desc_voice);
|
return context.getString(R.string.command_desc_voice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,34 +38,34 @@ import android.content.Context;
|
|||||||
*/
|
*/
|
||||||
public class WhoisHandler extends BaseHandler
|
public class WhoisHandler extends BaseHandler
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Execute /whois
|
* Execute /whois
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
|
||||||
{
|
{
|
||||||
if (params.length != 2) {
|
if (params.length != 2) {
|
||||||
throw new CommandException(service.getString(R.string.invalid_number_of_params));
|
throw new CommandException(service.getString(R.string.invalid_number_of_params));
|
||||||
}
|
}
|
||||||
|
|
||||||
service.getConnection(server.getId()).sendRawLineViaQueue("WHOIS " + params[1]);
|
service.getConnection(server.getId()).sendRawLineViaQueue("WHOIS " + params[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get description of /whois
|
* Get description of /whois
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getDescription(Context context)
|
public String getDescription(Context context)
|
||||||
{
|
{
|
||||||
return context.getString(R.string.command_desc_whois);
|
return context.getString(R.string.command_desc_whois);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get usage of /whois
|
* Get usage of /whois
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getUsage()
|
public String getUsage()
|
||||||
{
|
{
|
||||||
return "/whois <nickname>";
|
return "/whois <nickname>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,16 +4,16 @@ import android.provider.BaseColumns;
|
|||||||
|
|
||||||
public class AliasConstants implements BaseColumns {
|
public class AliasConstants implements BaseColumns {
|
||||||
|
|
||||||
public static final String TABLE_NAME = "aliases";
|
public static final String TABLE_NAME = "aliases";
|
||||||
|
|
||||||
// fields
|
// fields
|
||||||
public static final String ALIAS = "alias";
|
public static final String ALIAS = "alias";
|
||||||
public static final String IDENTITY = "identity";
|
public static final String IDENTITY = "identity";
|
||||||
|
|
||||||
public static final String[] ALL = {
|
public static final String[] ALL = {
|
||||||
_ID,
|
_ID,
|
||||||
ALIAS,
|
ALIAS,
|
||||||
IDENTITY,
|
IDENTITY,
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -29,19 +29,19 @@ import android.provider.BaseColumns;
|
|||||||
*/
|
*/
|
||||||
public interface ChannelConstants extends BaseColumns
|
public interface ChannelConstants extends BaseColumns
|
||||||
{
|
{
|
||||||
public static final String TABLE_NAME = "channels";
|
public static final String TABLE_NAME = "channels";
|
||||||
|
|
||||||
// fields
|
// fields
|
||||||
public static final String NAME = "name";
|
public static final String NAME = "name";
|
||||||
public static final String PASSWORD = "password";
|
public static final String PASSWORD = "password";
|
||||||
public static final String SERVER = "server";
|
public static final String SERVER = "server";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All fields of the table
|
* All fields of the table
|
||||||
*/
|
*/
|
||||||
public static final String[] ALL = {
|
public static final String[] ALL = {
|
||||||
NAME,
|
NAME,
|
||||||
PASSWORD,
|
PASSWORD,
|
||||||
SERVER
|
SERVER
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -29,17 +29,17 @@ import android.provider.BaseColumns;
|
|||||||
*/
|
*/
|
||||||
public interface CommandConstants extends BaseColumns
|
public interface CommandConstants extends BaseColumns
|
||||||
{
|
{
|
||||||
public static final String TABLE_NAME = "commands";
|
public static final String TABLE_NAME = "commands";
|
||||||
|
|
||||||
// fields
|
// fields
|
||||||
public static final String COMMAND = "command";
|
public static final String COMMAND = "command";
|
||||||
public static final String SERVER = "server";
|
public static final String SERVER = "server";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All fields of the table
|
* All fields of the table
|
||||||
*/
|
*/
|
||||||
public static final String[] ALL = {
|
public static final String[] ALL = {
|
||||||
COMMAND,
|
COMMAND,
|
||||||
SERVER
|
SERVER
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -29,20 +29,20 @@ import android.provider.BaseColumns;
|
|||||||
*/
|
*/
|
||||||
public class IdentityConstants implements BaseColumns
|
public class IdentityConstants implements BaseColumns
|
||||||
{
|
{
|
||||||
public static final String TABLE_NAME = "identities";
|
public static final String TABLE_NAME = "identities";
|
||||||
|
|
||||||
// fields
|
// fields
|
||||||
public static final String NICKNAME = "nickname";
|
public static final String NICKNAME = "nickname";
|
||||||
public static final String IDENT = "ident";
|
public static final String IDENT = "ident";
|
||||||
public static final String REALNAME = "realname";
|
public static final String REALNAME = "realname";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All fields of the table
|
* All fields of the table
|
||||||
*/
|
*/
|
||||||
public static final String[] ALL = {
|
public static final String[] ALL = {
|
||||||
_ID,
|
_ID,
|
||||||
NICKNAME,
|
NICKNAME,
|
||||||
IDENT,
|
IDENT,
|
||||||
REALNAME,
|
REALNAME,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -29,30 +29,30 @@ import android.provider.BaseColumns;
|
|||||||
*/
|
*/
|
||||||
public interface ServerConstants extends BaseColumns
|
public interface ServerConstants extends BaseColumns
|
||||||
{
|
{
|
||||||
public static final String TABLE_NAME = "servers";
|
public static final String TABLE_NAME = "servers";
|
||||||
|
|
||||||
// fields
|
// fields
|
||||||
public static final String TITLE = "title";
|
public static final String TITLE = "title";
|
||||||
public static final String HOST = "host";
|
public static final String HOST = "host";
|
||||||
public static final String PORT = "port";
|
public static final String PORT = "port";
|
||||||
public static final String PASSWORD = "password";
|
public static final String PASSWORD = "password";
|
||||||
public static final String AUTOCONNECT = "autoConnect";
|
public static final String AUTOCONNECT = "autoConnect";
|
||||||
public static final String USE_SSL = "useSSL";
|
public static final String USE_SSL = "useSSL";
|
||||||
public static final String CHARSET = "charset";
|
public static final String CHARSET = "charset";
|
||||||
public static final String IDENTITY = "identity";
|
public static final String IDENTITY = "identity";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All fields of the table
|
* All fields of the table
|
||||||
*/
|
*/
|
||||||
public static final String[] ALL = {
|
public static final String[] ALL = {
|
||||||
_ID,
|
_ID,
|
||||||
TITLE,
|
TITLE,
|
||||||
HOST,
|
HOST,
|
||||||
PORT,
|
PORT,
|
||||||
PASSWORD,
|
PASSWORD,
|
||||||
AUTOCONNECT,
|
AUTOCONNECT,
|
||||||
USE_SSL,
|
USE_SSL,
|
||||||
CHARSET,
|
CHARSET,
|
||||||
IDENTITY
|
IDENTITY
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -28,13 +28,13 @@ package org.yaaic.exception;
|
|||||||
*/
|
*/
|
||||||
public class CommandException extends Throwable
|
public class CommandException extends Throwable
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = -8317993941455253288L;
|
private static final long serialVersionUID = -8317993941455253288L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new CommandException object
|
* Create a new CommandException object
|
||||||
*/
|
*/
|
||||||
public CommandException(String message)
|
public CommandException(String message)
|
||||||
{
|
{
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,15 +27,15 @@ package org.yaaic.exception;
|
|||||||
*/
|
*/
|
||||||
public class ValidationException extends Exception
|
public class ValidationException extends Exception
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 6951535205062761539L;
|
private static final long serialVersionUID = 6951535205062761539L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new ValidationException with the given message
|
* Create a new ValidationException with the given message
|
||||||
*
|
*
|
||||||
* @param message The error message
|
* @param message The error message
|
||||||
*/
|
*/
|
||||||
public ValidationException(String message)
|
public ValidationException(String message)
|
||||||
{
|
{
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,36 +31,36 @@ import android.os.Binder;
|
|||||||
*/
|
*/
|
||||||
public class IRCBinder extends Binder
|
public class IRCBinder extends Binder
|
||||||
{
|
{
|
||||||
private IRCService service;
|
private IRCService service;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new binder for given service
|
* Create a new binder for given service
|
||||||
*
|
*
|
||||||
* @param service
|
* @param service
|
||||||
*/
|
*/
|
||||||
public IRCBinder(IRCService service)
|
public IRCBinder(IRCService service)
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.service = service;
|
this.service = service;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connect to given server
|
* Connect to given server
|
||||||
*
|
*
|
||||||
* @param server
|
* @param server
|
||||||
*/
|
*/
|
||||||
public void connect(final Server server)
|
public void connect(final Server server)
|
||||||
{
|
{
|
||||||
service.connect(server);
|
service.connect(server);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get service associated with this service
|
* Get service associated with this service
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public IRCService getService()
|
public IRCService getService()
|
||||||
{
|
{
|
||||||
return service;
|
return service;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -51,13 +51,13 @@ import android.content.Intent;
|
|||||||
*/
|
*/
|
||||||
public class IRCService extends Service
|
public class IRCService extends Service
|
||||||
{
|
{
|
||||||
private IRCBinder binder;
|
private IRCBinder binder;
|
||||||
private HashMap<Integer, IRCConnection> connections;
|
private HashMap<Integer, IRCConnection> connections;
|
||||||
private boolean foreground = false;
|
private boolean foreground = false;
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
private static final Class[] mStartForegroundSignature = new Class[] { int.class, Notification.class };
|
private static final Class[] mStartForegroundSignature = new Class[] { int.class, Notification.class };
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
private static final Class[] mStopForegroundSignature = new Class[] { boolean.class };
|
private static final Class[] mStopForegroundSignature = new Class[] { boolean.class };
|
||||||
|
|
||||||
public static final String ACTION_FOREGROUND = "org.yaaic.service.foreground";
|
public static final String ACTION_FOREGROUND = "org.yaaic.service.foreground";
|
||||||
@ -71,26 +71,26 @@ public class IRCService extends Service
|
|||||||
private Notification notification;
|
private Notification notification;
|
||||||
private Settings settings;
|
private Settings settings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create new service
|
* Create new service
|
||||||
*/
|
*/
|
||||||
public IRCService()
|
public IRCService()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.connections = new HashMap<Integer, IRCConnection>();
|
this.connections = new HashMap<Integer, IRCConnection>();
|
||||||
this.binder = new IRCBinder(this);
|
this.binder = new IRCBinder(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On create
|
* On create
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onCreate()
|
public void onCreate()
|
||||||
{
|
{
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
|
|
||||||
settings = new Settings(getBaseContext());
|
settings = new Settings(getBaseContext());
|
||||||
notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -101,49 +101,49 @@ public class IRCService extends Service
|
|||||||
mStartForeground = mStopForeground = null;
|
mStartForeground = mStopForeground = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load servers from Database
|
// Load servers from Database
|
||||||
Database db = new Database(this);
|
Database db = new Database(this);
|
||||||
Yaaic.getInstance().setServers(db.getServers());
|
Yaaic.getInstance().setServers(db.getServers());
|
||||||
db.close();
|
db.close();
|
||||||
|
|
||||||
// Broadcast changed server list
|
// Broadcast changed server list
|
||||||
sendBroadcast(new Intent(Broadcast.SERVER_UPDATE));
|
sendBroadcast(new Intent(Broadcast.SERVER_UPDATE));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Settings object
|
* Get Settings object
|
||||||
*
|
*
|
||||||
* @return the settings helper object
|
* @return the settings helper object
|
||||||
*/
|
*/
|
||||||
public Settings getSettings()
|
public Settings getSettings()
|
||||||
{
|
{
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On start (will be called on pre-2.0 platform. On 2.0 or later onStartCommand()
|
* On start (will be called on pre-2.0 platform. On 2.0 or later onStartCommand()
|
||||||
* will be called)
|
* will be called)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onStart(Intent intent, int startId)
|
public void onStart(Intent intent, int startId)
|
||||||
{
|
{
|
||||||
super.onStart(intent, startId);
|
super.onStart(intent, startId);
|
||||||
handleCommand(intent);
|
handleCommand(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On start command (Android >= 2.0)
|
* On start command (Android >= 2.0)
|
||||||
*
|
*
|
||||||
* @param intent
|
* @param intent
|
||||||
* @param flags
|
* @param flags
|
||||||
* @param startId
|
* @param startId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public int onStartCommand(Intent intent, int flags, int startId)
|
public int onStartCommand(Intent intent, int flags, int startId)
|
||||||
{
|
{
|
||||||
if (intent != null) {
|
if (intent != null) {
|
||||||
handleCommand(intent);
|
handleCommand(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We want this service to continue running until it is explicitly
|
// We want this service to continue running until it is explicitly
|
||||||
// stopped, so return sticky.
|
// stopped, so return sticky.
|
||||||
@ -160,22 +160,22 @@ public class IRCService extends Service
|
|||||||
private void handleCommand(Intent intent)
|
private void handleCommand(Intent intent)
|
||||||
{
|
{
|
||||||
if (ACTION_FOREGROUND.equals(intent.getAction())) {
|
if (ACTION_FOREGROUND.equals(intent.getAction())) {
|
||||||
if (foreground) {
|
if (foreground) {
|
||||||
return; // XXX: We are already in foreground...
|
return; // XXX: We are already in foreground...
|
||||||
}
|
}
|
||||||
foreground = true;
|
foreground = true;
|
||||||
|
|
||||||
// Set the icon, scrolling text and timestamp
|
// Set the icon, scrolling text and timestamp
|
||||||
notification = new Notification(R.drawable.icon, "", System.currentTimeMillis());
|
notification = new Notification(R.drawable.icon, "", System.currentTimeMillis());
|
||||||
|
|
||||||
// The PendingIntent to launch our activity if the user selects this notification
|
// The PendingIntent to launch our activity if the user selects this notification
|
||||||
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, ServersActivity.class), 0);
|
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, ServersActivity.class), 0);
|
||||||
|
|
||||||
// Set the info for the views that show in the notification panel.
|
// Set the info for the views that show in the notification panel.
|
||||||
notification.setLatestEventInfo(this, getText(R.string.app_name), "", contentIntent);
|
notification.setLatestEventInfo(this, getText(R.string.app_name), "", contentIntent);
|
||||||
|
|
||||||
startForegroundCompat(R.string.app_name, notification);
|
startForegroundCompat(R.string.app_name, notification);
|
||||||
} else if (ACTION_BACKGROUND.equals(intent.getAction()) && !foreground) {
|
} else if (ACTION_BACKGROUND.equals(intent.getAction()) && !foreground) {
|
||||||
stopForegroundCompat(R.string.app_name);
|
stopForegroundCompat(R.string.app_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -193,21 +193,21 @@ public class IRCService extends Service
|
|||||||
/**
|
/**
|
||||||
* Update notification and vibrate if needed
|
* Update notification and vibrate if needed
|
||||||
*
|
*
|
||||||
* @param text The text to display
|
* @param text The text to display
|
||||||
* @param vibrate True if the device should vibrate, false otherwise
|
* @param vibrate True if the device should vibrate, false otherwise
|
||||||
*/
|
*/
|
||||||
public void updateNotification(String text, boolean vibrate)
|
public void updateNotification(String text, boolean vibrate)
|
||||||
{
|
{
|
||||||
if (foreground) {
|
if (foreground) {
|
||||||
notificationManager.cancel(R.string.app_name);
|
notificationManager.cancel(R.string.app_name);
|
||||||
notification = new Notification(R.drawable.icon, text, System.currentTimeMillis());
|
notification = new Notification(R.drawable.icon, text, System.currentTimeMillis());
|
||||||
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, ServersActivity.class), 0);
|
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, ServersActivity.class), 0);
|
||||||
notification.setLatestEventInfo(this, getText(R.string.app_name), text, contentIntent);
|
notification.setLatestEventInfo(this, getText(R.string.app_name), text, contentIntent);
|
||||||
if (vibrate) {
|
if (vibrate) {
|
||||||
notification.defaults |= Notification.DEFAULT_VIBRATE;
|
notification.defaults |= Notification.DEFAULT_VIBRATE;
|
||||||
}
|
}
|
||||||
notificationManager.notify(R.string.app_name, notification);
|
notificationManager.notify(R.string.app_name, notification);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -228,9 +228,9 @@ public class IRCService extends Service
|
|||||||
// Should not happen.
|
// Should not happen.
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Fall back on the old API.
|
// Fall back on the old API.
|
||||||
setForeground(true);
|
setForeground(true);
|
||||||
notificationManager.notify(id, notification);
|
notificationManager.notify(id, notification);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,7 +240,7 @@ public class IRCService extends Service
|
|||||||
*/
|
*/
|
||||||
public void stopForegroundCompat(int id)
|
public void stopForegroundCompat(int id)
|
||||||
{
|
{
|
||||||
foreground = false;
|
foreground = false;
|
||||||
|
|
||||||
// If we have the new stopForeground API, then use it.
|
// If we have the new stopForeground API, then use it.
|
||||||
if (mStopForeground != null) {
|
if (mStopForeground != null) {
|
||||||
@ -253,10 +253,10 @@ public class IRCService extends Service
|
|||||||
// Should not happen.
|
// Should not happen.
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Fall back on the old API. Note to cancel BEFORE changing the
|
// Fall back on the old API. Note to cancel BEFORE changing the
|
||||||
// foreground state, since we could be killed at that point.
|
// foreground state, since we could be killed at that point.
|
||||||
notificationManager.cancel(id);
|
notificationManager.cancel(id);
|
||||||
setForeground(false);
|
setForeground(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,135 +265,135 @@ public class IRCService extends Service
|
|||||||
*/
|
*/
|
||||||
public void connect(final Server server)
|
public void connect(final Server server)
|
||||||
{
|
{
|
||||||
new Thread() {
|
new Thread() {
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
IRCConnection connection = getConnection(server.getId());
|
IRCConnection connection = getConnection(server.getId());
|
||||||
|
|
||||||
connection.setNickname(server.getIdentity().getNickname());
|
connection.setNickname(server.getIdentity().getNickname());
|
||||||
connection.setAliases(server.getIdentity().getAliases());
|
connection.setAliases(server.getIdentity().getAliases());
|
||||||
connection.setIdent(server.getIdentity().getIdent());
|
connection.setIdent(server.getIdentity().getIdent());
|
||||||
connection.setRealName(server.getIdentity().getRealName());
|
connection.setRealName(server.getIdentity().getRealName());
|
||||||
connection.setUseSSL(server.useSSL());
|
connection.setUseSSL(server.useSSL());
|
||||||
|
|
||||||
if (server.getCharset() != null) {
|
if (server.getCharset() != null) {
|
||||||
connection.setEncoding(server.getCharset());
|
connection.setEncoding(server.getCharset());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (server.getPassword() != "") {
|
if (server.getPassword() != "") {
|
||||||
connection.connect(server.getHost(), server.getPort(), server.getPassword());
|
connection.connect(server.getHost(), server.getPort(), server.getPassword());
|
||||||
} else {
|
} else {
|
||||||
connection.connect(server.getHost(), server.getPort());
|
connection.connect(server.getHost(), server.getPort());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
server.setStatus(Status.DISCONNECTED);
|
server.setStatus(Status.DISCONNECTED);
|
||||||
|
|
||||||
Intent sIntent = Broadcast.createServerIntent(Broadcast.SERVER_UPDATE, server.getId());
|
Intent sIntent = Broadcast.createServerIntent(Broadcast.SERVER_UPDATE, server.getId());
|
||||||
sendBroadcast(sIntent);
|
sendBroadcast(sIntent);
|
||||||
|
|
||||||
IRCConnection connection = getConnection(server.getId());
|
IRCConnection connection = getConnection(server.getId());
|
||||||
|
|
||||||
Message message;
|
Message message;
|
||||||
|
|
||||||
if (e instanceof NickAlreadyInUseException) {
|
if (e instanceof NickAlreadyInUseException) {
|
||||||
message = new Message(getString(R.string.nickname_in_use, connection.getNick()));
|
message = new Message(getString(R.string.nickname_in_use, connection.getNick()));
|
||||||
} else if (e instanceof IrcException) {
|
} else if (e instanceof IrcException) {
|
||||||
message = new Message(getString(R.string.irc_login_error, server.getHost(), server.getPort()));
|
message = new Message(getString(R.string.irc_login_error, server.getHost(), server.getPort()));
|
||||||
} else {
|
} else {
|
||||||
message = new Message(getString(R.string.could_not_connect, server.getHost(), server.getPort()));
|
message = new Message(getString(R.string.could_not_connect, server.getHost(), server.getPort()));
|
||||||
}
|
}
|
||||||
|
|
||||||
message.setColor(Message.COLOR_RED);
|
message.setColor(Message.COLOR_RED);
|
||||||
message.setIcon(R.drawable.error);
|
message.setIcon(R.drawable.error);
|
||||||
server.getConversation(ServerInfo.DEFAULT_NAME).addMessage(message);
|
server.getConversation(ServerInfo.DEFAULT_NAME).addMessage(message);
|
||||||
|
|
||||||
Intent cIntent = Broadcast.createConversationIntent(
|
Intent cIntent = Broadcast.createConversationIntent(
|
||||||
Broadcast.CONVERSATION_MESSAGE,
|
Broadcast.CONVERSATION_MESSAGE,
|
||||||
server.getId(),
|
server.getId(),
|
||||||
ServerInfo.DEFAULT_NAME
|
ServerInfo.DEFAULT_NAME
|
||||||
);
|
);
|
||||||
sendBroadcast(cIntent);
|
sendBroadcast(cIntent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.start();
|
}.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get connection for given server
|
* Get connection for given server
|
||||||
*
|
*
|
||||||
* @param serverId
|
* @param serverId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public synchronized IRCConnection getConnection(int serverId)
|
public synchronized IRCConnection getConnection(int serverId)
|
||||||
{
|
{
|
||||||
IRCConnection connection = connections.get(serverId);
|
IRCConnection connection = connections.get(serverId);
|
||||||
|
|
||||||
if (connection == null) {
|
if (connection == null) {
|
||||||
connection = new IRCConnection(this, serverId);
|
connection = new IRCConnection(this, serverId);
|
||||||
connections.put(serverId, connection);
|
connections.put(serverId, connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
return connection;
|
return connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Does the service keep a connection object for this server?
|
* Does the service keep a connection object for this server?
|
||||||
*
|
*
|
||||||
* @return true if there's a connection object, false otherwise
|
* @return true if there's a connection object, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean hasConnection(int serverId)
|
public boolean hasConnection(int serverId)
|
||||||
{
|
{
|
||||||
return connections.containsKey(serverId);
|
return connections.containsKey(serverId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check status of service
|
* Check status of service
|
||||||
*/
|
*/
|
||||||
public void checkServiceStatus()
|
public void checkServiceStatus()
|
||||||
{
|
{
|
||||||
boolean shutDown = true;
|
boolean shutDown = true;
|
||||||
ArrayList<Server> mServers = Yaaic.getInstance().getServersAsArrayList();
|
ArrayList<Server> mServers = Yaaic.getInstance().getServersAsArrayList();
|
||||||
int mSize = mServers.size();
|
int mSize = mServers.size();
|
||||||
Server server;
|
Server server;
|
||||||
|
|
||||||
for (int i = 0; i < mSize; i++) {
|
for (int i = 0; i < mSize; i++) {
|
||||||
server = mServers.get(i);
|
server = mServers.get(i);
|
||||||
if (server.isDisconnected()) {
|
if (server.isDisconnected()) {
|
||||||
connections.remove(server.getId());
|
connections.remove(server.getId());
|
||||||
} else {
|
} else {
|
||||||
shutDown = false;
|
shutDown = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shutDown) {
|
if (shutDown) {
|
||||||
foreground = false;
|
foreground = false;
|
||||||
stopForegroundCompat(R.string.app_name);
|
stopForegroundCompat(R.string.app_name);
|
||||||
stopSelf();
|
stopSelf();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On Destroy
|
* On Destroy
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy()
|
public void onDestroy()
|
||||||
{
|
{
|
||||||
// Make sure our notification is gone.
|
// Make sure our notification is gone.
|
||||||
if (foreground) {
|
if (foreground) {
|
||||||
stopForegroundCompat(R.string.app_name);
|
stopForegroundCompat(R.string.app_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On Activity binding to this service
|
* On Activity binding to this service
|
||||||
*
|
*
|
||||||
* @param intent
|
* @param intent
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public IRCBinder onBind(Intent intent)
|
public IRCBinder onBind(Intent intent)
|
||||||
{
|
{
|
||||||
return binder;
|
return binder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,14 +53,14 @@ public class NonScalingBackgroundDrawable extends Drawable {
|
|||||||
*/
|
*/
|
||||||
public void draw(Canvas canvas)
|
public void draw(Canvas canvas)
|
||||||
{
|
{
|
||||||
int left = (view.getWidth() / 2) - (drawable.getIntrinsicWidth() / 2);
|
int left = (view.getWidth() / 2) - (drawable.getIntrinsicWidth() / 2);
|
||||||
int top = (view.getHeight() / 2) - (drawable.getIntrinsicHeight() / 2);
|
int top = (view.getHeight() / 2) - (drawable.getIntrinsicHeight() / 2);
|
||||||
int right = left + drawable.getIntrinsicWidth();
|
int right = left + drawable.getIntrinsicWidth();
|
||||||
int bottom = top + drawable.getIntrinsicHeight();
|
int bottom = top + drawable.getIntrinsicHeight();
|
||||||
|
|
||||||
drawable.setBounds(left, top, right, bottom);
|
drawable.setBounds(left, top, right, bottom);
|
||||||
|
|
||||||
drawable.draw(canvas);
|
drawable.draw(canvas);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -76,7 +76,7 @@ public class NonScalingBackgroundDrawable extends Drawable {
|
|||||||
*/
|
*/
|
||||||
public void setAlpha(int alpha)
|
public void setAlpha(int alpha)
|
||||||
{
|
{
|
||||||
drawable.setAlpha(alpha);
|
drawable.setAlpha(alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -84,6 +84,6 @@ public class NonScalingBackgroundDrawable extends Drawable {
|
|||||||
*/
|
*/
|
||||||
public void setColorFilter(ColorFilter cf)
|
public void setColorFilter(ColorFilter cf)
|
||||||
{
|
{
|
||||||
drawable.setColorFilter(cf);
|
drawable.setColorFilter(cf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,35 +38,35 @@ import org.yaaic.view.MessageListView;
|
|||||||
*/
|
*/
|
||||||
public class ConversationClickListener implements OnItemClickListener
|
public class ConversationClickListener implements OnItemClickListener
|
||||||
{
|
{
|
||||||
private DeckAdapter adapter;
|
private DeckAdapter adapter;
|
||||||
private ViewSwitcher switcher;
|
private ViewSwitcher switcher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new ConversationClickListener
|
* Create a new ConversationClickListener
|
||||||
*
|
*
|
||||||
* @param adapter
|
* @param adapter
|
||||||
* @param switcher
|
* @param switcher
|
||||||
*/
|
*/
|
||||||
public ConversationClickListener(DeckAdapter adapter, ViewSwitcher switcher)
|
public ConversationClickListener(DeckAdapter adapter, ViewSwitcher switcher)
|
||||||
{
|
{
|
||||||
this.adapter = adapter;
|
this.adapter = adapter;
|
||||||
this.switcher = switcher;
|
this.switcher = switcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On conversation item clicked
|
* On conversation item clicked
|
||||||
*/
|
*/
|
||||||
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id)
|
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id)
|
||||||
{
|
{
|
||||||
Conversation conversation = adapter.getItem(position);
|
Conversation conversation = adapter.getItem(position);
|
||||||
|
|
||||||
MessageListView canvas = adapter.renderConversation(conversation, switcher);
|
MessageListView canvas = adapter.renderConversation(conversation, switcher);
|
||||||
canvas.setTranscriptMode(ListView.TRANSCRIPT_MODE_NORMAL);
|
canvas.setTranscriptMode(ListView.TRANSCRIPT_MODE_NORMAL);
|
||||||
canvas.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
|
canvas.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
|
||||||
canvas.setDelegateTouchEvents(false); // Do not delegate
|
canvas.setDelegateTouchEvents(false); // Do not delegate
|
||||||
|
|
||||||
adapter.setSwitched(conversation.getName(), canvas);
|
adapter.setSwitched(conversation.getName(), canvas);
|
||||||
switcher.addView(canvas);
|
switcher.addView(canvas);
|
||||||
switcher.showNext();
|
switcher.showNext();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ package org.yaaic.listener;
|
|||||||
|
|
||||||
public interface ConversationListener
|
public interface ConversationListener
|
||||||
{
|
{
|
||||||
public void onConversationMessage(String target);
|
public void onConversationMessage(String target);
|
||||||
public void onNewConversation(String target);
|
public void onNewConversation(String target);
|
||||||
public void onRemoveConversation(String target);
|
public void onRemoveConversation(String target);
|
||||||
}
|
}
|
||||||
|
@ -36,56 +36,56 @@ import org.yaaic.view.ConversationSwitcher;
|
|||||||
*/
|
*/
|
||||||
public class ConversationSelectedListener implements OnItemSelectedListener
|
public class ConversationSelectedListener implements OnItemSelectedListener
|
||||||
{
|
{
|
||||||
private Server server;
|
private Server server;
|
||||||
private TextView titleView;
|
private TextView titleView;
|
||||||
private ConversationSwitcher switcher;
|
private ConversationSwitcher switcher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new ConversationSelectedListener
|
* Create a new ConversationSelectedListener
|
||||||
*
|
*
|
||||||
* @param server
|
* @param server
|
||||||
* @param titleView
|
* @param titleView
|
||||||
*/
|
*/
|
||||||
public ConversationSelectedListener(Server server, TextView titleView, ConversationSwitcher switcher)
|
public ConversationSelectedListener(Server server, TextView titleView, ConversationSwitcher switcher)
|
||||||
{
|
{
|
||||||
this.server = server;
|
this.server = server;
|
||||||
this.titleView = titleView;
|
this.titleView = titleView;
|
||||||
this.switcher = switcher;
|
this.switcher = switcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On conversation selected/focused
|
* On conversation selected/focused
|
||||||
*/
|
*/
|
||||||
public void onItemSelected(AdapterView<?> deck, View view, int position, long id)
|
public void onItemSelected(AdapterView<?> deck, View view, int position, long id)
|
||||||
{
|
{
|
||||||
Conversation conversation = (Conversation) deck.getItemAtPosition(position);
|
Conversation conversation = (Conversation) deck.getItemAtPosition(position);
|
||||||
|
|
||||||
if (conversation != null && conversation.getType() != Conversation.TYPE_SERVER) {
|
if (conversation != null && conversation.getType() != Conversation.TYPE_SERVER) {
|
||||||
titleView.setText(server.getTitle() + " - " + conversation.getName());
|
titleView.setText(server.getTitle() + " - " + conversation.getName());
|
||||||
} else {
|
} else {
|
||||||
onNothingSelected(deck);
|
onNothingSelected(deck);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remember selection
|
// Remember selection
|
||||||
if (conversation != null) {
|
if (conversation != null) {
|
||||||
Conversation previousConversation = server.getConversation(server.getSelectedConversation());
|
Conversation previousConversation = server.getConversation(server.getSelectedConversation());
|
||||||
|
|
||||||
if (previousConversation != null) {
|
if (previousConversation != null) {
|
||||||
previousConversation.setStatus(Conversation.STATUS_DEFAULT);
|
previousConversation.setStatus(Conversation.STATUS_DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
conversation.setStatus(Conversation.STATUS_SELECTED);
|
conversation.setStatus(Conversation.STATUS_SELECTED);
|
||||||
server.setSelectedConversation(conversation.getName());
|
server.setSelectedConversation(conversation.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
switcher.invalidate();
|
switcher.invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On no conversation selected/focused
|
* On no conversation selected/focused
|
||||||
*/
|
*/
|
||||||
public void onNothingSelected(AdapterView<?> deck)
|
public void onNothingSelected(AdapterView<?> deck)
|
||||||
{
|
{
|
||||||
titleView.setText(server.getTitle());
|
titleView.setText(server.getTitle());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,38 +36,38 @@ import android.widget.AdapterView.OnItemClickListener;
|
|||||||
*/
|
*/
|
||||||
public class MessageClickListener implements OnItemClickListener
|
public class MessageClickListener implements OnItemClickListener
|
||||||
{
|
{
|
||||||
private static MessageClickListener instance;
|
private static MessageClickListener instance;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private constructor
|
* Private constructor
|
||||||
*/
|
*/
|
||||||
private MessageClickListener()
|
private MessageClickListener()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get global instance of message click listener
|
* Get global instance of message click listener
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static synchronized MessageClickListener getInstance()
|
public static synchronized MessageClickListener getInstance()
|
||||||
{
|
{
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
instance = new MessageClickListener();
|
instance = new MessageClickListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On message item clicked
|
* On message item clicked
|
||||||
*/
|
*/
|
||||||
public void onItemClick(AdapterView<?> group, View view, int position, long id)
|
public void onItemClick(AdapterView<?> group, View view, int position, long id)
|
||||||
{
|
{
|
||||||
MessageListAdapter adapter = (MessageListAdapter) group.getAdapter();
|
MessageListAdapter adapter = (MessageListAdapter) group.getAdapter();
|
||||||
|
|
||||||
Intent intent = new Intent(group.getContext(), MessageActivity.class);
|
Intent intent = new Intent(group.getContext(), MessageActivity.class);
|
||||||
intent.putExtra(Extra.MESSAGE, adapter.getItem(position).getText().toString());
|
intent.putExtra(Extra.MESSAGE, adapter.getItem(position).getText().toString());
|
||||||
group.getContext().startActivity(intent);
|
group.getContext().startActivity(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,5 +22,5 @@ package org.yaaic.listener;
|
|||||||
|
|
||||||
public interface ServerListener
|
public interface ServerListener
|
||||||
{
|
{
|
||||||
public void onStatusUpdate();
|
public void onStatusUpdate();
|
||||||
}
|
}
|
||||||
|
@ -35,29 +35,29 @@ import android.view.View.OnClickListener;
|
|||||||
*/
|
*/
|
||||||
public class SpeechClickListener implements OnClickListener
|
public class SpeechClickListener implements OnClickListener
|
||||||
{
|
{
|
||||||
private Activity activity;
|
private Activity activity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new listener for speech button
|
* Create a new listener for speech button
|
||||||
*
|
*
|
||||||
* @param activity
|
* @param activity
|
||||||
* @param input
|
* @param input
|
||||||
*/
|
*/
|
||||||
public SpeechClickListener(Activity activity)
|
public SpeechClickListener(Activity activity)
|
||||||
{
|
{
|
||||||
this.activity = activity;
|
this.activity = activity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On Click on speech button
|
* On Click on speech button
|
||||||
*/
|
*/
|
||||||
public void onClick(View v)
|
public void onClick(View v)
|
||||||
{
|
{
|
||||||
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
|
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
|
||||||
|
|
||||||
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
|
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
|
||||||
intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "");
|
intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "");
|
||||||
|
|
||||||
activity.startActivityForResult(intent, ConversationActivity.REQUEST_CODE_SPEECH);
|
activity.startActivityForResult(intent, ConversationActivity.REQUEST_CODE_SPEECH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,43 +29,43 @@ import android.content.Intent;
|
|||||||
*/
|
*/
|
||||||
public abstract class Broadcast
|
public abstract class Broadcast
|
||||||
{
|
{
|
||||||
public static final String SERVER_UPDATE = "org.yaaic.server.status";
|
public static final String SERVER_UPDATE = "org.yaaic.server.status";
|
||||||
|
|
||||||
public static final String CONVERSATION_MESSAGE = "org.yaaic.conversation.message";
|
public static final String CONVERSATION_MESSAGE = "org.yaaic.conversation.message";
|
||||||
public static final String CONVERSATION_NEW = "org.yaaic.conversation.new";
|
public static final String CONVERSATION_NEW = "org.yaaic.conversation.new";
|
||||||
public static final String CONVERSATION_REMOVE = "org.yaaic.conversation.remove";
|
public static final String CONVERSATION_REMOVE = "org.yaaic.conversation.remove";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an Intent for conversation broadcasting
|
* Create an Intent for conversation broadcasting
|
||||||
*
|
*
|
||||||
* @param broadcastType The type of the broadcast, some constant of Broadcast.*
|
* @param broadcastType The type of the broadcast, some constant of Broadcast.*
|
||||||
* @param serverId The id of the server
|
* @param serverId The id of the server
|
||||||
* @param conversationName The unique name of the conversation
|
* @param conversationName The unique name of the conversation
|
||||||
* @return The created Intent
|
* @return The created Intent
|
||||||
*/
|
*/
|
||||||
public static Intent createConversationIntent(String broadcastType, int serverId, String conversationName)
|
public static Intent createConversationIntent(String broadcastType, int serverId, String conversationName)
|
||||||
{
|
{
|
||||||
Intent intent = new Intent(broadcastType);
|
Intent intent = new Intent(broadcastType);
|
||||||
|
|
||||||
intent.putExtra(Extra.SERVER, serverId);
|
intent.putExtra(Extra.SERVER, serverId);
|
||||||
intent.putExtra(Extra.CONVERSATION, conversationName);
|
intent.putExtra(Extra.CONVERSATION, conversationName);
|
||||||
|
|
||||||
return intent;
|
return intent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an Intent for server broadcasting
|
* Create an Intent for server broadcasting
|
||||||
*
|
*
|
||||||
* @param broadcastType The typo of the broadcast, some constant of Broadcast.*
|
* @param broadcastType The typo of the broadcast, some constant of Broadcast.*
|
||||||
* @param serverId The id of the server
|
* @param serverId The id of the server
|
||||||
* @return The created Intent
|
* @return The created Intent
|
||||||
*/
|
*/
|
||||||
public static Intent createServerIntent(String broadcastType, int serverId)
|
public static Intent createServerIntent(String broadcastType, int serverId)
|
||||||
{
|
{
|
||||||
Intent intent = new Intent(broadcastType);
|
Intent intent = new Intent(broadcastType);
|
||||||
|
|
||||||
intent.putExtra(Extra.SERVER, serverId);
|
intent.putExtra(Extra.SERVER, serverId);
|
||||||
|
|
||||||
return intent;
|
return intent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,45 +27,45 @@ package org.yaaic.model;
|
|||||||
*/
|
*/
|
||||||
public class Channel extends Conversation
|
public class Channel extends Conversation
|
||||||
{
|
{
|
||||||
private String topic;
|
private String topic;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new channel object
|
* Create a new channel object
|
||||||
*
|
*
|
||||||
* @param name of the channel
|
* @param name of the channel
|
||||||
*/
|
*/
|
||||||
public Channel(String name)
|
public Channel(String name)
|
||||||
{
|
{
|
||||||
super(name);
|
super(name);
|
||||||
this.topic = "";
|
this.topic = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the type of this conversation
|
* Get the type of this conversation
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int getType()
|
public int getType()
|
||||||
{
|
{
|
||||||
return Conversation.TYPE_CHANNEL;
|
return Conversation.TYPE_CHANNEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the channel's topic
|
* Set the channel's topic
|
||||||
*
|
*
|
||||||
* @param topic The topic of the channel
|
* @param topic The topic of the channel
|
||||||
*/
|
*/
|
||||||
public void setTopic(String topic)
|
public void setTopic(String topic)
|
||||||
{
|
{
|
||||||
this.topic = topic;
|
this.topic = topic;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the topic of the channel
|
* Get the topic of the channel
|
||||||
*
|
*
|
||||||
* @return The channel's topic
|
* @return The channel's topic
|
||||||
*/
|
*/
|
||||||
public String getTopic()
|
public String getTopic()
|
||||||
{
|
{
|
||||||
return topic;
|
return topic;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,163 +33,163 @@ import org.yaaic.adapter.MessageListAdapter;
|
|||||||
*/
|
*/
|
||||||
public abstract class Conversation
|
public abstract class Conversation
|
||||||
{
|
{
|
||||||
public static final int TYPE_CHANNEL = 1;
|
public static final int TYPE_CHANNEL = 1;
|
||||||
public static final int TYPE_QUERY = 2;
|
public static final int TYPE_QUERY = 2;
|
||||||
public static final int TYPE_SERVER = 3;
|
public static final int TYPE_SERVER = 3;
|
||||||
|
|
||||||
public static final int STATUS_DEFAULT = 1;
|
public static final int STATUS_DEFAULT = 1;
|
||||||
public static final int STATUS_SELECTED = 2;
|
public static final int STATUS_SELECTED = 2;
|
||||||
public static final int STATUS_MESSAGE = 3;
|
public static final int STATUS_MESSAGE = 3;
|
||||||
public static final int STATUS_HIGHLIGHT = 4;
|
public static final int STATUS_HIGHLIGHT = 4;
|
||||||
|
|
||||||
public static final int HISTORY_SIZE = 30;
|
public static final int HISTORY_SIZE = 30;
|
||||||
|
|
||||||
private LinkedList<Message> buffer;
|
private LinkedList<Message> buffer;
|
||||||
private LinkedList<Message> history;
|
private LinkedList<Message> history;
|
||||||
private String name;
|
private String name;
|
||||||
private MessageListAdapter adapter;
|
private MessageListAdapter adapter;
|
||||||
private int status = 1;
|
private int status = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the type of conversation (channel, query, ..)
|
* Get the type of conversation (channel, query, ..)
|
||||||
*
|
*
|
||||||
* @return See the constants: Conversation.TYPE_*
|
* @return See the constants: Conversation.TYPE_*
|
||||||
*/
|
*/
|
||||||
public abstract int getType();
|
public abstract int getType();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new conversation with the given name
|
* Create a new conversation with the given name
|
||||||
*
|
*
|
||||||
* @param name The name of the conversation (channel, user)
|
* @param name The name of the conversation (channel, user)
|
||||||
*/
|
*/
|
||||||
public Conversation(String name)
|
public Conversation(String name)
|
||||||
{
|
{
|
||||||
this.buffer = new LinkedList<Message>();
|
this.buffer = new LinkedList<Message>();
|
||||||
this.history = new LinkedList<Message>();
|
this.history = new LinkedList<Message>();
|
||||||
this.name = name.toLowerCase();
|
this.name = name.toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get name of the conversation (channel, user)
|
* Get name of the conversation (channel, user)
|
||||||
*/
|
*/
|
||||||
public String getName()
|
public String getName()
|
||||||
{
|
{
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a message to the channel
|
* Add a message to the channel
|
||||||
*/
|
*/
|
||||||
public void addMessage(Message message)
|
public void addMessage(Message message)
|
||||||
{
|
{
|
||||||
buffer.add(0, message);
|
buffer.add(0, message);
|
||||||
history.add(message);
|
history.add(message);
|
||||||
|
|
||||||
if (history.size() > HISTORY_SIZE) {
|
if (history.size() > HISTORY_SIZE) {
|
||||||
history.remove(0);
|
history.remove(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the history
|
* Get the history
|
||||||
*/
|
*/
|
||||||
public LinkedList<Message> getHistory()
|
public LinkedList<Message> getHistory()
|
||||||
{
|
{
|
||||||
return history;
|
return history;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get message of the history at the given position
|
* Get message of the history at the given position
|
||||||
*
|
*
|
||||||
* @param position
|
* @param position
|
||||||
* @return The message at the given position
|
* @return The message at the given position
|
||||||
*/
|
*/
|
||||||
public Message getHistoryMessage(int position)
|
public Message getHistoryMessage(int position)
|
||||||
{
|
{
|
||||||
return history.get(position);
|
return history.get(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get last buffered message
|
* Get last buffered message
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Message pollBufferedMessage()
|
public Message pollBufferedMessage()
|
||||||
{
|
{
|
||||||
Message message = buffer.get(buffer.size() - 1);
|
Message message = buffer.get(buffer.size() - 1);
|
||||||
buffer.remove(buffer.size() - 1);
|
buffer.remove(buffer.size() - 1);
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the buffer
|
* Get the buffer
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public LinkedList<Message> getBuffer()
|
public LinkedList<Message> getBuffer()
|
||||||
{
|
{
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Does the channel have buffered messages?
|
* Does the channel have buffered messages?
|
||||||
*/
|
*/
|
||||||
public boolean hasBufferedMessages()
|
public boolean hasBufferedMessages()
|
||||||
{
|
{
|
||||||
return buffer.size() > 0;
|
return buffer.size() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear the message buffer
|
* Clear the message buffer
|
||||||
*/
|
*/
|
||||||
public void clearBuffer()
|
public void clearBuffer()
|
||||||
{
|
{
|
||||||
buffer.clear();
|
buffer.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Store the adapter of this conversation
|
* Store the adapter of this conversation
|
||||||
*/
|
*/
|
||||||
public void setMessageListAdapter(MessageListAdapter adapter)
|
public void setMessageListAdapter(MessageListAdapter adapter)
|
||||||
{
|
{
|
||||||
this.adapter = adapter;
|
this.adapter = adapter;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the MessageList Adapter of this conversation if known
|
* Get the MessageList Adapter of this conversation if known
|
||||||
*/
|
*/
|
||||||
public MessageListAdapter getMessageListAdapter()
|
public MessageListAdapter getMessageListAdapter()
|
||||||
{
|
{
|
||||||
return adapter;
|
return adapter;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set status of conversation
|
* Set status of conversation
|
||||||
*
|
*
|
||||||
* @param status
|
* @param status
|
||||||
*/
|
*/
|
||||||
public void setStatus(int status)
|
public void setStatus(int status)
|
||||||
{
|
{
|
||||||
// Selected status can only be changed by deselecting
|
// Selected status can only be changed by deselecting
|
||||||
if (this.status == STATUS_SELECTED && status != STATUS_DEFAULT) {
|
if (this.status == STATUS_SELECTED && status != STATUS_DEFAULT) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Highlight status can only be changed by selecting
|
// Highlight status can only be changed by selecting
|
||||||
if (this.status == STATUS_HIGHLIGHT && status != STATUS_SELECTED) {
|
if (this.status == STATUS_HIGHLIGHT && status != STATUS_SELECTED) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get status of conversation
|
* Get status of conversation
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public int getStatus()
|
public int getStatus()
|
||||||
{
|
{
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,14 +27,14 @@ package org.yaaic.model;
|
|||||||
*/
|
*/
|
||||||
public class Extra
|
public class Extra
|
||||||
{
|
{
|
||||||
public static final String SERVER = "server";
|
public static final String SERVER = "server";
|
||||||
public static final String CONVERSATION = "conversation";
|
public static final String CONVERSATION = "conversation";
|
||||||
public static final String USERS = "users";
|
public static final String USERS = "users";
|
||||||
|
|
||||||
public static final String ALIASES = "aliases";
|
public static final String ALIASES = "aliases";
|
||||||
public static final String CHANNELS = "channels";
|
public static final String CHANNELS = "channels";
|
||||||
public static final String COMMANDS = "commands";
|
public static final String COMMANDS = "commands";
|
||||||
public static final String MESSAGE = "message";
|
public static final String MESSAGE = "message";
|
||||||
public static final String USER = "user";
|
public static final String USER = "user";
|
||||||
public static final String ACTION = "action";
|
public static final String ACTION = "action";
|
||||||
}
|
}
|
||||||
|
@ -32,77 +32,77 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class Identity
|
public class Identity
|
||||||
{
|
{
|
||||||
private String nickname;
|
private String nickname;
|
||||||
private List<String> aliases = new ArrayList<String>();
|
private List<String> aliases = new ArrayList<String>();
|
||||||
private String ident;
|
private String ident;
|
||||||
private String realname;
|
private String realname;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the nickname of this identity
|
* Set the nickname of this identity
|
||||||
*
|
*
|
||||||
* @param nickname The nickname to be set
|
* @param nickname The nickname to be set
|
||||||
*/
|
*/
|
||||||
public void setNickname(String nickname)
|
public void setNickname(String nickname)
|
||||||
{
|
{
|
||||||
this.nickname = nickname;
|
this.nickname = nickname;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the nickname of this identity
|
* Get the nickname of this identity
|
||||||
*
|
*
|
||||||
* @return The nickname
|
* @return The nickname
|
||||||
*/
|
*/
|
||||||
public String getNickname()
|
public String getNickname()
|
||||||
{
|
{
|
||||||
return nickname;
|
return nickname;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAliases(Collection<String> aliases) {
|
public void setAliases(Collection<String> aliases) {
|
||||||
this.aliases.clear();
|
this.aliases.clear();
|
||||||
this.aliases.addAll(aliases);
|
this.aliases.addAll(aliases);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getAliases() {
|
public List<String> getAliases() {
|
||||||
return Collections.unmodifiableList(aliases);
|
return Collections.unmodifiableList(aliases);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the ident of this identity
|
* Set the ident of this identity
|
||||||
*
|
*
|
||||||
* @param ident The ident to be set
|
* @param ident The ident to be set
|
||||||
*/
|
*/
|
||||||
public void setIdent(String ident)
|
public void setIdent(String ident)
|
||||||
{
|
{
|
||||||
this.ident = ident;
|
this.ident = ident;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the ident of this identity
|
* Get the ident of this identity
|
||||||
*
|
*
|
||||||
* @return The identity
|
* @return The identity
|
||||||
*/
|
*/
|
||||||
public String getIdent()
|
public String getIdent()
|
||||||
{
|
{
|
||||||
return ident;
|
return ident;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the real name of this identity
|
* Set the real name of this identity
|
||||||
*
|
*
|
||||||
* @param realname The real name to be set
|
* @param realname The real name to be set
|
||||||
*/
|
*/
|
||||||
public void setRealName(String realname)
|
public void setRealName(String realname)
|
||||||
{
|
{
|
||||||
this.realname = realname;
|
this.realname = realname;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the real name of this identity
|
* Get the real name of this identity
|
||||||
*
|
*
|
||||||
* @return The realname
|
* @return The realname
|
||||||
*/
|
*/
|
||||||
public String getRealName()
|
public String getRealName()
|
||||||
{
|
{
|
||||||
return realname;
|
return realname;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,191 +37,191 @@ import android.widget.TextView;
|
|||||||
* @author Sebastian Kaspari <sebastian@yaaic.org>
|
* @author Sebastian Kaspari <sebastian@yaaic.org>
|
||||||
*/
|
*/
|
||||||
public class Message {
|
public class Message {
|
||||||
public static final int COLOR_GREEN = 0xFF458509;
|
public static final int COLOR_GREEN = 0xFF458509;
|
||||||
public static final int COLOR_RED = 0xFFcc0000;
|
public static final int COLOR_RED = 0xFFcc0000;
|
||||||
public static final int COLOR_BLUE = 0xFF729fcf;
|
public static final int COLOR_BLUE = 0xFF729fcf;
|
||||||
public static final int COLOR_YELLOW = 0xFFbe9b01;
|
public static final int COLOR_YELLOW = 0xFFbe9b01;
|
||||||
public static final int COLOR_GREY = 0xFFaaaaaa;
|
public static final int COLOR_GREY = 0xFFaaaaaa;
|
||||||
public static final int COLOR_DEFAULT = 0xFFeeeeee;
|
public static final int COLOR_DEFAULT = 0xFFeeeeee;
|
||||||
|
|
||||||
public static final int[] colors = {
|
public static final int[] colors = {
|
||||||
0xFFffffff, //White
|
0xFFffffff, //White
|
||||||
0xFFffff00, //Yellow
|
0xFFffff00, //Yellow
|
||||||
0xFFff00ff, //Fuchsia
|
0xFFff00ff, //Fuchsia
|
||||||
0xFFff0000, //Red
|
0xFFff0000, //Red
|
||||||
0xFFc0c0c0, //Silver
|
0xFFc0c0c0, //Silver
|
||||||
0xFF808080, //Gray
|
0xFF808080, //Gray
|
||||||
0xFF808000, //Olive
|
0xFF808000, //Olive
|
||||||
0xFF800080, //Purple
|
0xFF800080, //Purple
|
||||||
0xFF800000, //Maroon
|
0xFF800000, //Maroon
|
||||||
0xFF00ffff, //Agua
|
0xFF00ffff, //Agua
|
||||||
0xFF00ff00, //Lime
|
0xFF00ff00, //Lime
|
||||||
0xFF008080, //Teal
|
0xFF008080, //Teal
|
||||||
0xFF008000, //Green
|
0xFF008000, //Green
|
||||||
0xFF0000FF, //Blue
|
0xFF0000FF, //Blue
|
||||||
0xFF000080, //Navy
|
0xFF000080, //Navy
|
||||||
0xFF000000, //Black
|
0xFF000000, //Black
|
||||||
};
|
};
|
||||||
|
|
||||||
private int icon = -1;
|
private int icon = -1;
|
||||||
private String text;
|
private String text;
|
||||||
private String sender;
|
private String sender;
|
||||||
private SpannableString canvas;
|
private SpannableString canvas;
|
||||||
private int color = -1;
|
private int color = -1;
|
||||||
private long timestamp;
|
private long timestamp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new message without an icon
|
* Create a new message without an icon
|
||||||
*
|
*
|
||||||
* @param text
|
* @param text
|
||||||
*/
|
*/
|
||||||
public Message(String text)
|
public Message(String text)
|
||||||
{
|
{
|
||||||
this(text, null);
|
this(text, null);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Create a new message sent by a user without an icon
|
* Create a new message sent by a user without an icon
|
||||||
*
|
*
|
||||||
* @param text
|
* @param text
|
||||||
* @param sender
|
* @param sender
|
||||||
*/
|
*/
|
||||||
public Message(String text, String sender)
|
public Message(String text, String sender)
|
||||||
{
|
{
|
||||||
this.text = text;
|
this.text = text;
|
||||||
this.sender = sender;
|
this.sender = sender;
|
||||||
this.timestamp = new Date().getTime();
|
this.timestamp = new Date().getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the message's icon
|
* Set the message's icon
|
||||||
*/
|
*/
|
||||||
public void setIcon(int icon)
|
public void setIcon(int icon)
|
||||||
{
|
{
|
||||||
this.icon = icon;
|
this.icon = icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the message's icon
|
* Get the message's icon
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public int getIcon()
|
public int getIcon()
|
||||||
{
|
{
|
||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the text of this message
|
* Get the text of this message
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String getText()
|
public String getText()
|
||||||
{
|
{
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the color of this message
|
* Set the color of this message
|
||||||
*/
|
*/
|
||||||
public void setColor(int color)
|
public void setColor(int color)
|
||||||
{
|
{
|
||||||
this.color = color;
|
this.color = color;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Associate a color with a sender name
|
* Associate a color with a sender name
|
||||||
*
|
*
|
||||||
* @return a color hexa
|
* @return a color hexa
|
||||||
*/
|
*/
|
||||||
private int getSenderColor()
|
private int getSenderColor()
|
||||||
{
|
{
|
||||||
/* It might be worth to use some hash table here */
|
/* It might be worth to use some hash table here */
|
||||||
if (sender == null) return COLOR_DEFAULT;
|
if (sender == null) return COLOR_DEFAULT;
|
||||||
int color = 0;
|
int color = 0;
|
||||||
for(int i = 0; i < sender.length(); i++){
|
for(int i = 0; i < sender.length(); i++){
|
||||||
color += sender.charAt(i);
|
color += sender.charAt(i);
|
||||||
}
|
}
|
||||||
/* we dont want color[colors.length-1] which is black */
|
/* we dont want color[colors.length-1] which is black */
|
||||||
color = color % (colors.length - 1);
|
color = color % (colors.length - 1);
|
||||||
return colors[color];
|
return colors[color];
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Render message as spannable string
|
* Render message as spannable string
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public SpannableString render(Context context)
|
public SpannableString render(Context context)
|
||||||
{
|
{
|
||||||
Settings settings = new Settings(context);
|
Settings settings = new Settings(context);
|
||||||
|
|
||||||
if (canvas == null) {
|
if (canvas == null) {
|
||||||
String prefix = icon != -1 && settings.showIcons() ? " " : "";
|
String prefix = icon != -1 && settings.showIcons() ? " " : "";
|
||||||
String nick = sender != null ? "<" + sender + "> " : "";
|
String nick = sender != null ? "<" + sender + "> " : "";
|
||||||
String timestamp = settings.showTimestamp() ? Message.generateTimestamp(this.timestamp, settings.use24hFormat()) : "";
|
String timestamp = settings.showTimestamp() ? Message.generateTimestamp(this.timestamp, settings.use24hFormat()) : "";
|
||||||
|
|
||||||
canvas = new SpannableString(prefix + timestamp + nick + text);
|
canvas = new SpannableString(prefix + timestamp + nick + text);
|
||||||
|
|
||||||
if (sender != null) {
|
if (sender != null) {
|
||||||
int start = (prefix + timestamp).length() + 1;
|
int start = (prefix + timestamp).length() + 1;
|
||||||
int end = start + sender.length();
|
int end = start + sender.length();
|
||||||
if (settings.showColorsNick()) {
|
if (settings.showColorsNick()) {
|
||||||
canvas.setSpan(new ForegroundColorSpan(getSenderColor()), start, end , Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
canvas.setSpan(new ForegroundColorSpan(getSenderColor()), start, end , Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (icon != -1 && settings.showIcons()) {
|
if (icon != -1 && settings.showIcons()) {
|
||||||
Drawable drawable = context.getResources().getDrawable(icon);
|
Drawable drawable = context.getResources().getDrawable(icon);
|
||||||
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
|
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
|
||||||
canvas.setSpan(new ImageSpan(drawable, ImageSpan.ALIGN_BOTTOM), 0, 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
canvas.setSpan(new ImageSpan(drawable, ImageSpan.ALIGN_BOTTOM), 0, 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||||
}
|
}
|
||||||
if (color != -1 && settings.showColors()) {
|
if (color != -1 && settings.showColors()) {
|
||||||
canvas.setSpan(new ForegroundColorSpan(color), 0, canvas.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
canvas.setSpan(new ForegroundColorSpan(color), 0, canvas.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return canvas;
|
return canvas;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render message as text view
|
* Render message as text view
|
||||||
*
|
*
|
||||||
* @param context
|
* @param context
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public TextView renderTextView(Context context)
|
public TextView renderTextView(Context context)
|
||||||
{
|
{
|
||||||
// XXX: We should not read settings here ALWAYS for EVERY textview
|
// XXX: We should not read settings here ALWAYS for EVERY textview
|
||||||
Settings settings = new Settings(context);
|
Settings settings = new Settings(context);
|
||||||
|
|
||||||
TextView canvas = new TextView(context);
|
TextView canvas = new TextView(context);
|
||||||
|
|
||||||
canvas.setText(this.render(context));
|
canvas.setText(this.render(context));
|
||||||
canvas.setTextSize(settings.getFontSize());
|
canvas.setTextSize(settings.getFontSize());
|
||||||
canvas.setTypeface(Typeface.MONOSPACE);
|
canvas.setTypeface(Typeface.MONOSPACE);
|
||||||
canvas.setTextColor(COLOR_DEFAULT);
|
canvas.setTextColor(COLOR_DEFAULT);
|
||||||
|
|
||||||
return canvas;
|
return canvas;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a timestamp
|
* Generate a timestamp
|
||||||
*
|
*
|
||||||
* @param use24hFormat
|
* @param use24hFormat
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static String generateTimestamp(long timestamp, boolean use24hFormat)
|
public static String generateTimestamp(long timestamp, boolean use24hFormat)
|
||||||
{
|
{
|
||||||
Date date = new Date(timestamp);
|
Date date = new Date(timestamp);
|
||||||
|
|
||||||
int hours = date.getHours();
|
int hours = date.getHours();
|
||||||
int minutes = date.getMinutes();
|
int minutes = date.getMinutes();
|
||||||
|
|
||||||
if (!use24hFormat) {
|
if (!use24hFormat) {
|
||||||
hours = Math.abs(12 - hours);
|
hours = Math.abs(12 - hours);
|
||||||
if (hours == 12) {
|
if (hours == 12) {
|
||||||
hours = 0;
|
hours = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return "[" + (hours < 10 ? "0" + hours : hours) + ":" + (minutes < 10 ? "0" + minutes : minutes) + "] ";
|
return "[" + (hours < 10 ? "0" + hours : hours) + ":" + (minutes < 10 ? "0" + minutes : minutes) + "] ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,21 +27,21 @@ package org.yaaic.model;
|
|||||||
*/
|
*/
|
||||||
public class Query extends Conversation
|
public class Query extends Conversation
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Create a new query
|
* Create a new query
|
||||||
*
|
*
|
||||||
* @param name The user's nickname
|
* @param name The user's nickname
|
||||||
*/
|
*/
|
||||||
public Query(String name)
|
public Query(String name)
|
||||||
{
|
{
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the type of this conversation
|
* Get the type of this conversation
|
||||||
*/
|
*/
|
||||||
public int getType()
|
public int getType()
|
||||||
{
|
{
|
||||||
return Conversation.TYPE_QUERY;
|
return Conversation.TYPE_QUERY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,68 +29,68 @@ import java.util.LinkedList;
|
|||||||
*/
|
*/
|
||||||
public class Scrollback
|
public class Scrollback
|
||||||
{
|
{
|
||||||
public static final int MAX_HISTORY = 10;
|
public static final int MAX_HISTORY = 10;
|
||||||
|
|
||||||
private LinkedList<String> messages;
|
private LinkedList<String> messages;
|
||||||
private int pointer;
|
private int pointer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new scrollback object
|
* Create a new scrollback object
|
||||||
*/
|
*/
|
||||||
public Scrollback()
|
public Scrollback()
|
||||||
{
|
{
|
||||||
messages = new LinkedList<String>();
|
messages = new LinkedList<String>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a message to the history
|
* Add a message to the history
|
||||||
*/
|
*/
|
||||||
public void addMessage(String message)
|
public void addMessage(String message)
|
||||||
{
|
{
|
||||||
messages.addLast(message);
|
messages.addLast(message);
|
||||||
|
|
||||||
if (messages.size() > MAX_HISTORY) {
|
if (messages.size() > MAX_HISTORY) {
|
||||||
messages.removeFirst();
|
messages.removeFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
pointer = messages.size();
|
pointer = messages.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Go back in history
|
* Go back in history
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String goBack()
|
public String goBack()
|
||||||
{
|
{
|
||||||
if (pointer > 0) {
|
if (pointer > 0) {
|
||||||
pointer--;
|
pointer--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (messages.size() > 0) {
|
if (messages.size() > 0) {
|
||||||
return messages.get(pointer);
|
return messages.get(pointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Go forward in history
|
* Go forward in history
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String goForward()
|
public String goForward()
|
||||||
{
|
{
|
||||||
if (pointer < messages.size() - 1) {
|
if (pointer < messages.size() - 1) {
|
||||||
pointer++;
|
pointer++;
|
||||||
} else {
|
} else {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (messages.size() > 0) {
|
if (messages.size() > 0) {
|
||||||
return messages.get(pointer);
|
return messages.get(pointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,375 +33,375 @@ import org.yaaic.R;
|
|||||||
*/
|
*/
|
||||||
public class Server
|
public class Server
|
||||||
{
|
{
|
||||||
private int id;
|
private int id;
|
||||||
private String title;
|
private String title;
|
||||||
private String host;
|
private String host;
|
||||||
private int port;
|
private int port;
|
||||||
private String password;
|
private String password;
|
||||||
private String charset;
|
private String charset;
|
||||||
private boolean useSSL = false;
|
private boolean useSSL = false;
|
||||||
private Identity identity;
|
private Identity identity;
|
||||||
|
|
||||||
private LinkedHashMap<String, Conversation> conversations = new LinkedHashMap<String, Conversation>();
|
private LinkedHashMap<String, Conversation> conversations = new LinkedHashMap<String, Conversation>();
|
||||||
private ArrayList<String> autoJoinChannels;
|
private ArrayList<String> autoJoinChannels;
|
||||||
private ArrayList<String> connectCommands;
|
private ArrayList<String> connectCommands;
|
||||||
|
|
||||||
private int status = Status.DISCONNECTED;
|
private int status = Status.DISCONNECTED;
|
||||||
private String selected = "";
|
private String selected = "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new server object
|
* Create a new server object
|
||||||
*/
|
*/
|
||||||
public Server()
|
public Server()
|
||||||
{
|
{
|
||||||
conversations.put(ServerInfo.DEFAULT_NAME, new ServerInfo());
|
conversations.put(ServerInfo.DEFAULT_NAME, new ServerInfo());
|
||||||
this.selected = ServerInfo.DEFAULT_NAME;
|
this.selected = ServerInfo.DEFAULT_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the identity for this server
|
* Set the identity for this server
|
||||||
*
|
*
|
||||||
* @param identity The identity for this server
|
* @param identity The identity for this server
|
||||||
*/
|
*/
|
||||||
public void setIdentity(Identity identity)
|
public void setIdentity(Identity identity)
|
||||||
{
|
{
|
||||||
this.identity = identity;
|
this.identity = identity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the identity for this server
|
* Get the identity for this server
|
||||||
*
|
*
|
||||||
* @return identity
|
* @return identity
|
||||||
*/
|
*/
|
||||||
public Identity getIdentity()
|
public Identity getIdentity()
|
||||||
{
|
{
|
||||||
return identity;
|
return identity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get unique id of server
|
* Get unique id of server
|
||||||
*
|
*
|
||||||
* @return id
|
* @return id
|
||||||
*/
|
*/
|
||||||
public int getId()
|
public int getId()
|
||||||
{
|
{
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set unique id of server
|
* Set unique id of server
|
||||||
*
|
*
|
||||||
* @param id
|
* @param id
|
||||||
*/
|
*/
|
||||||
public void setId(int id)
|
public void setId(int id)
|
||||||
{
|
{
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set password of the server
|
* Set password of the server
|
||||||
*
|
*
|
||||||
* @param password The password of the server
|
* @param password The password of the server
|
||||||
*/
|
*/
|
||||||
public void setPassword(String password)
|
public void setPassword(String password)
|
||||||
{
|
{
|
||||||
this.password = password;
|
this.password = password;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the password of the server
|
* Get the password of the server
|
||||||
*
|
*
|
||||||
* @return The password of the server
|
* @return The password of the server
|
||||||
*/
|
*/
|
||||||
public String getPassword()
|
public String getPassword()
|
||||||
{
|
{
|
||||||
return password;
|
return password;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get title of server
|
* Get title of server
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String getTitle()
|
public String getTitle()
|
||||||
{
|
{
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set title of server
|
* Set title of server
|
||||||
*
|
*
|
||||||
* @param title
|
* @param title
|
||||||
*/
|
*/
|
||||||
public void setTitle(String title)
|
public void setTitle(String title)
|
||||||
{
|
{
|
||||||
this.title = title;
|
this.title = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get hostname of server
|
* Get hostname of server
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String getHost()
|
public String getHost()
|
||||||
{
|
{
|
||||||
return host;
|
return host;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set hostname of server
|
* Set hostname of server
|
||||||
*
|
*
|
||||||
* @param host
|
* @param host
|
||||||
*/
|
*/
|
||||||
public void setHost(String host)
|
public void setHost(String host)
|
||||||
{
|
{
|
||||||
this.host = host;
|
this.host = host;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get port of server
|
* Get port of server
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public int getPort()
|
public int getPort()
|
||||||
{
|
{
|
||||||
return port;
|
return port;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set port of server
|
* Set port of server
|
||||||
*
|
*
|
||||||
* @param port
|
* @param port
|
||||||
*/
|
*/
|
||||||
public void setPort(int port)
|
public void setPort(int port)
|
||||||
{
|
{
|
||||||
this.port = port;
|
this.port = port;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the charset to be used for all messages sent to the server
|
* Set the charset to be used for all messages sent to the server
|
||||||
*
|
*
|
||||||
* @param charset The name of the charset
|
* @param charset The name of the charset
|
||||||
*/
|
*/
|
||||||
public void setCharset(String charset)
|
public void setCharset(String charset)
|
||||||
{
|
{
|
||||||
this.charset = charset;
|
this.charset = charset;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the charset to be used with this server
|
* Get the charset to be used with this server
|
||||||
*
|
*
|
||||||
* @return String charset The name of the charset
|
* @return String charset The name of the charset
|
||||||
*/
|
*/
|
||||||
public String getCharset()
|
public String getCharset()
|
||||||
{
|
{
|
||||||
return charset;
|
return charset;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set if this connections needs to use ssl
|
* Set if this connections needs to use ssl
|
||||||
*/
|
*/
|
||||||
public void setUseSSL(boolean useSSL)
|
public void setUseSSL(boolean useSSL)
|
||||||
{
|
{
|
||||||
this.useSSL = useSSL;
|
this.useSSL = useSSL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Does this connection use SSL?
|
* Does this connection use SSL?
|
||||||
*
|
*
|
||||||
* @return true if SSL should be used, false otherwise
|
* @return true if SSL should be used, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean useSSL()
|
public boolean useSSL()
|
||||||
{
|
{
|
||||||
return useSSL;
|
return useSSL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set connection status of server
|
* Set connection status of server
|
||||||
*
|
*
|
||||||
* @status See constants Status.*
|
* @status See constants Status.*
|
||||||
*/
|
*/
|
||||||
public void setStatus(int status)
|
public void setStatus(int status)
|
||||||
{
|
{
|
||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get connection status of server
|
* Get connection status of server
|
||||||
*
|
*
|
||||||
* @return See constants Status.*
|
* @return See constants Status.*
|
||||||
*/
|
*/
|
||||||
public int getStatus()
|
public int getStatus()
|
||||||
{
|
{
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set list of channels to auto join after connect
|
* Set list of channels to auto join after connect
|
||||||
*
|
*
|
||||||
* @param channels List of channel names
|
* @param channels List of channel names
|
||||||
*/
|
*/
|
||||||
public void setAutoJoinChannels(ArrayList<String> autoJoinChannels)
|
public void setAutoJoinChannels(ArrayList<String> autoJoinChannels)
|
||||||
{
|
{
|
||||||
this.autoJoinChannels = autoJoinChannels;
|
this.autoJoinChannels = autoJoinChannels;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get list of channels to auto join after connect
|
* Get list of channels to auto join after connect
|
||||||
*
|
*
|
||||||
* @return List of channel names
|
* @return List of channel names
|
||||||
*/
|
*/
|
||||||
public ArrayList<String> getAutoJoinChannels()
|
public ArrayList<String> getAutoJoinChannels()
|
||||||
{
|
{
|
||||||
return autoJoinChannels;
|
return autoJoinChannels;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set commands to execute after connect
|
* Set commands to execute after connect
|
||||||
*
|
*
|
||||||
* @param commands List of commands
|
* @param commands List of commands
|
||||||
*/
|
*/
|
||||||
public void setConnectCommands(ArrayList<String> connectCommands)
|
public void setConnectCommands(ArrayList<String> connectCommands)
|
||||||
{
|
{
|
||||||
this.connectCommands = connectCommands;
|
this.connectCommands = connectCommands;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get commands to execute after connect
|
* Get commands to execute after connect
|
||||||
*
|
*
|
||||||
* @return List of commands
|
* @return List of commands
|
||||||
*/
|
*/
|
||||||
public ArrayList<String> getConnectCommands()
|
public ArrayList<String> getConnectCommands()
|
||||||
{
|
{
|
||||||
return connectCommands;
|
return connectCommands;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is disconnected?
|
* Is disconnected?
|
||||||
*
|
*
|
||||||
* @return true if the user is disconnected, false if the user is connected or currently connecting
|
* @return true if the user is disconnected, false if the user is connected or currently connecting
|
||||||
*/
|
*/
|
||||||
public boolean isDisconnected()
|
public boolean isDisconnected()
|
||||||
{
|
{
|
||||||
return status == Status.DISCONNECTED;
|
return status == Status.DISCONNECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is connected?
|
* Is connected?
|
||||||
*
|
*
|
||||||
* @return true if the user is (successfully) connected to this server, false otherwise
|
* @return true if the user is (successfully) connected to this server, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean isConnected()
|
public boolean isConnected()
|
||||||
{
|
{
|
||||||
return status == Status.CONNECTED;
|
return status == Status.CONNECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all conversations
|
* Get all conversations
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Collection<Conversation> getConversations()
|
public Collection<Conversation> getConversations()
|
||||||
{
|
{
|
||||||
return conversations.values();
|
return conversations.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get conversation by name
|
* Get conversation by name
|
||||||
*/
|
*/
|
||||||
public Conversation getConversation(String name)
|
public Conversation getConversation(String name)
|
||||||
{
|
{
|
||||||
return conversations.get(name.toLowerCase());
|
return conversations.get(name.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new conversation
|
* Add a new conversation
|
||||||
*
|
*
|
||||||
* @param conversation The conversation to add
|
* @param conversation The conversation to add
|
||||||
*/
|
*/
|
||||||
public void addConversationl(Conversation conversation)
|
public void addConversationl(Conversation conversation)
|
||||||
{
|
{
|
||||||
conversations.put(conversation.getName().toLowerCase(), conversation);
|
conversations.put(conversation.getName().toLowerCase(), conversation);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a conversation by name
|
* Removes a conversation by name
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name
|
||||||
*/
|
*/
|
||||||
public void removeConversation(String name)
|
public void removeConversation(String name)
|
||||||
{
|
{
|
||||||
conversations.remove(name.toLowerCase());
|
conversations.remove(name.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove all conversations
|
* Remove all conversations
|
||||||
*/
|
*/
|
||||||
public void clearConversations()
|
public void clearConversations()
|
||||||
{
|
{
|
||||||
conversations.clear();
|
conversations.clear();
|
||||||
|
|
||||||
// reset defaults
|
// reset defaults
|
||||||
conversations.put(ServerInfo.DEFAULT_NAME, new ServerInfo());
|
conversations.put(ServerInfo.DEFAULT_NAME, new ServerInfo());
|
||||||
this.selected = ServerInfo.DEFAULT_NAME;
|
this.selected = ServerInfo.DEFAULT_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set name of currently selected conversation
|
* Set name of currently selected conversation
|
||||||
*
|
*
|
||||||
* @param selected The name of the selected conversation
|
* @param selected The name of the selected conversation
|
||||||
*/
|
*/
|
||||||
public void setSelectedConversation(String selected)
|
public void setSelectedConversation(String selected)
|
||||||
{
|
{
|
||||||
this.selected = selected;
|
this.selected = selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get name of currently selected conversation
|
* Get name of currently selected conversation
|
||||||
*
|
*
|
||||||
* @return The name of the selected conversation
|
* @return The name of the selected conversation
|
||||||
*/
|
*/
|
||||||
public String getSelectedConversation()
|
public String getSelectedConversation()
|
||||||
{
|
{
|
||||||
return selected;
|
return selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get names of the currently joined channels
|
* Get names of the currently joined channels
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public ArrayList<String> getCurrentChannelNames()
|
public ArrayList<String> getCurrentChannelNames()
|
||||||
{
|
{
|
||||||
ArrayList<String> channels = new ArrayList<String>();
|
ArrayList<String> channels = new ArrayList<String>();
|
||||||
Collection<Conversation> mConversations = conversations.values();
|
Collection<Conversation> mConversations = conversations.values();
|
||||||
|
|
||||||
for (Conversation conversation : mConversations) {
|
for (Conversation conversation : mConversations) {
|
||||||
if (conversation.getType() == Conversation.TYPE_CHANNEL) {
|
if (conversation.getType() == Conversation.TYPE_CHANNEL) {
|
||||||
channels.add(conversation.getName());
|
channels.add(conversation.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return channels;
|
return channels;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get icon for current server status
|
* Get icon for current server status
|
||||||
*
|
*
|
||||||
* @return int Status icon ressource
|
* @return int Status icon ressource
|
||||||
*/
|
*/
|
||||||
public int getStatusIcon()
|
public int getStatusIcon()
|
||||||
{
|
{
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case Status.CONNECTED:
|
case Status.CONNECTED:
|
||||||
return R.drawable.connected;
|
return R.drawable.connected;
|
||||||
case Status.DISCONNECTED:
|
case Status.DISCONNECTED:
|
||||||
return R.drawable.disconnected;
|
return R.drawable.disconnected;
|
||||||
case Status.PRE_CONNECTING:
|
case Status.PRE_CONNECTING:
|
||||||
case Status.CONNECTING:
|
case Status.CONNECTING:
|
||||||
return R.drawable.connecting;
|
return R.drawable.connecting;
|
||||||
}
|
}
|
||||||
|
|
||||||
return R.drawable.connecting;
|
return R.drawable.connecting;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,24 +27,24 @@ package org.yaaic.model;
|
|||||||
*/
|
*/
|
||||||
public class ServerInfo extends Conversation
|
public class ServerInfo extends Conversation
|
||||||
{
|
{
|
||||||
public static final String DEFAULT_NAME = "";
|
public static final String DEFAULT_NAME = "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new ServerInfo object
|
* Create a new ServerInfo object
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name
|
||||||
*/
|
*/
|
||||||
public ServerInfo()
|
public ServerInfo()
|
||||||
{
|
{
|
||||||
super(DEFAULT_NAME);
|
super(DEFAULT_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the type of this conversation
|
* Get the type of this conversation
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int getType()
|
public int getType()
|
||||||
{
|
{
|
||||||
return Conversation.TYPE_SERVER;
|
return Conversation.TYPE_SERVER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,143 +32,143 @@ import android.preference.PreferenceManager;
|
|||||||
* small and simple methods.
|
* small and simple methods.
|
||||||
*
|
*
|
||||||
* Note: As this class carries a Context instace as private member, instances of
|
* Note: As this class carries a Context instace as private member, instances of
|
||||||
* this class should be thrown away not later than when the Context should
|
* this class should be thrown away not later than when the Context should
|
||||||
* be gone. Otherwise this could leak memory.
|
* be gone. Otherwise this could leak memory.
|
||||||
*
|
*
|
||||||
* @author Sebastian Kaspari <sebastian@yaaic.org>
|
* @author Sebastian Kaspari <sebastian@yaaic.org>
|
||||||
*/
|
*/
|
||||||
public class Settings
|
public class Settings
|
||||||
{
|
{
|
||||||
private SharedPreferences preferences;
|
private SharedPreferences preferences;
|
||||||
private Resources resources;
|
private Resources resources;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new Settings instance
|
* Create a new Settings instance
|
||||||
*
|
*
|
||||||
* @param context
|
* @param context
|
||||||
*/
|
*/
|
||||||
public Settings(Context context)
|
public Settings(Context context)
|
||||||
{
|
{
|
||||||
this.preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
this.preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
this.resources = context.getApplicationContext().getResources();
|
this.resources = context.getApplicationContext().getResources();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prefix all messages with a timestamp?
|
* Prefix all messages with a timestamp?
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean showTimestamp()
|
public boolean showTimestamp()
|
||||||
{
|
{
|
||||||
return preferences.getBoolean(
|
return preferences.getBoolean(
|
||||||
resources.getString(R.string.key_show_timestamp),
|
resources.getString(R.string.key_show_timestamp),
|
||||||
Boolean.parseBoolean(resources.getString(R.string.default_show_timestamp))
|
Boolean.parseBoolean(resources.getString(R.string.default_show_timestamp))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show icons to highlight special events
|
* Show icons to highlight special events
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean showIcons()
|
public boolean showIcons()
|
||||||
{
|
{
|
||||||
return preferences.getBoolean(
|
return preferences.getBoolean(
|
||||||
resources.getString(R.string.key_show_icons),
|
resources.getString(R.string.key_show_icons),
|
||||||
Boolean.parseBoolean(resources.getString(R.string.default_show_icons))
|
Boolean.parseBoolean(resources.getString(R.string.default_show_icons))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show colors to highlight special events?
|
* Show colors to highlight special events?
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean showColors()
|
public boolean showColors()
|
||||||
{
|
{
|
||||||
return preferences.getBoolean(
|
return preferences.getBoolean(
|
||||||
resources.getString(R.string.key_show_colors),
|
resources.getString(R.string.key_show_colors),
|
||||||
Boolean.parseBoolean(resources.getString(R.string.default_show_colors))
|
Boolean.parseBoolean(resources.getString(R.string.default_show_colors))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show colors to highlight nicknames?
|
* Show colors to highlight nicknames?
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean showColorsNick()
|
public boolean showColorsNick()
|
||||||
{
|
{
|
||||||
return preferences.getBoolean(
|
return preferences.getBoolean(
|
||||||
resources.getString(R.string.key_show_colors_nick),
|
resources.getString(R.string.key_show_colors_nick),
|
||||||
Boolean.parseBoolean(resources.getString(R.string.default_show_colors_nick))
|
Boolean.parseBoolean(resources.getString(R.string.default_show_colors_nick))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use 24 hour format for timestamps?
|
* Use 24 hour format for timestamps?
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean use24hFormat()
|
public boolean use24hFormat()
|
||||||
{
|
{
|
||||||
return preferences.getBoolean(
|
return preferences.getBoolean(
|
||||||
resources.getString(R.string.key_24h_format),
|
resources.getString(R.string.key_24h_format),
|
||||||
Boolean.parseBoolean(resources.getString(R.string.default_24h_format))
|
Boolean.parseBoolean(resources.getString(R.string.default_24h_format))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is reconnect on disconnect enabled?
|
* Is reconnect on disconnect enabled?
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean isReconnectEnabled()
|
public boolean isReconnectEnabled()
|
||||||
{
|
{
|
||||||
return preferences.getBoolean(
|
return preferences.getBoolean(
|
||||||
resources.getString(R.string.key_reconnect),
|
resources.getString(R.string.key_reconnect),
|
||||||
Boolean.parseBoolean(resources.getString(R.string.default_reconnect))
|
Boolean.parseBoolean(resources.getString(R.string.default_reconnect))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the quit message
|
* Get the quit message
|
||||||
*
|
*
|
||||||
* @return The message to display when the user disconnects
|
* @return The message to display when the user disconnects
|
||||||
*/
|
*/
|
||||||
public String getQuitMessage()
|
public String getQuitMessage()
|
||||||
{
|
{
|
||||||
return preferences.getString(
|
return preferences.getString(
|
||||||
resources.getString(R.string.key_quitmessage),
|
resources.getString(R.string.key_quitmessage),
|
||||||
resources.getString(R.string.default_quitmessage)
|
resources.getString(R.string.default_quitmessage)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the font size
|
* Get the font size
|
||||||
*
|
*
|
||||||
* @return The font size for conversation messages
|
* @return The font size for conversation messages
|
||||||
*/
|
*/
|
||||||
public int getFontSize()
|
public int getFontSize()
|
||||||
{
|
{
|
||||||
return Integer.parseInt(preferences.getString(
|
return Integer.parseInt(preferences.getString(
|
||||||
resources.getString(R.string.key_fontsize),
|
resources.getString(R.string.key_fontsize),
|
||||||
resources.getString(R.string.default_fontsize)
|
resources.getString(R.string.default_fontsize)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is voice recognition enabled?
|
* Is voice recognition enabled?
|
||||||
*
|
*
|
||||||
* @return True if voice recognition is enabled, false otherwise
|
* @return True if voice recognition is enabled, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean isVoiceRecognitionEnabled()
|
public boolean isVoiceRecognitionEnabled()
|
||||||
{
|
{
|
||||||
return preferences.getBoolean(
|
return preferences.getBoolean(
|
||||||
resources.getString(R.string.key_voice_recognition),
|
resources.getString(R.string.key_voice_recognition),
|
||||||
Boolean.parseBoolean(resources.getString(R.string.default_voice_recognition))
|
Boolean.parseBoolean(resources.getString(R.string.default_voice_recognition))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Vibrate on highlight?
|
* Vibrate on highlight?
|
||||||
|
@ -26,8 +26,8 @@ package org.yaaic.model;
|
|||||||
* @author Sebastian Kaspari <sebastian@yaaic.org>
|
* @author Sebastian Kaspari <sebastian@yaaic.org>
|
||||||
*/
|
*/
|
||||||
public class Status {
|
public class Status {
|
||||||
public static final int DISCONNECTED = 0;
|
public static final int DISCONNECTED = 0;
|
||||||
public static final int CONNECTING = 1;
|
public static final int CONNECTING = 1;
|
||||||
public static final int CONNECTED = 2;
|
public static final int CONNECTED = 2;
|
||||||
public static final int PRE_CONNECTING = 3;
|
public static final int PRE_CONNECTING = 3;
|
||||||
}
|
}
|
||||||
|
@ -35,44 +35,44 @@ import org.yaaic.model.Extra;
|
|||||||
*/
|
*/
|
||||||
public class ConversationReceiver extends BroadcastReceiver
|
public class ConversationReceiver extends BroadcastReceiver
|
||||||
{
|
{
|
||||||
private ConversationListener listener;
|
private ConversationListener listener;
|
||||||
private int serverId;
|
private int serverId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new channel receiver
|
* Create a new channel receiver
|
||||||
*
|
*
|
||||||
* @param serverId Only listen on channels of this server
|
* @param serverId Only listen on channels of this server
|
||||||
* @param listener
|
* @param listener
|
||||||
*/
|
*/
|
||||||
public ConversationReceiver(int serverId, ConversationListener listener)
|
public ConversationReceiver(int serverId, ConversationListener listener)
|
||||||
{
|
{
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
this.serverId = serverId;
|
this.serverId = serverId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On receive broadcast
|
* On receive broadcast
|
||||||
*
|
*
|
||||||
* @param context
|
* @param context
|
||||||
* @param intent
|
* @param intent
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent)
|
public void onReceive(Context context, Intent intent)
|
||||||
{
|
{
|
||||||
int serverId = intent.getExtras().getInt(Extra.SERVER);
|
int serverId = intent.getExtras().getInt(Extra.SERVER);
|
||||||
if (serverId != this.serverId) {
|
if (serverId != this.serverId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String action = intent.getAction();
|
String action = intent.getAction();
|
||||||
|
|
||||||
if (action.equals(Broadcast.CONVERSATION_MESSAGE)) {
|
if (action.equals(Broadcast.CONVERSATION_MESSAGE)) {
|
||||||
listener.onConversationMessage(intent.getExtras().getString(Extra.CONVERSATION));
|
listener.onConversationMessage(intent.getExtras().getString(Extra.CONVERSATION));
|
||||||
} else if (action.equals(Broadcast.CONVERSATION_NEW)) {
|
} else if (action.equals(Broadcast.CONVERSATION_NEW)) {
|
||||||
listener.onNewConversation(intent.getExtras().getString(Extra.CONVERSATION));
|
listener.onNewConversation(intent.getExtras().getString(Extra.CONVERSATION));
|
||||||
} else if (action.equals(Broadcast.CONVERSATION_REMOVE)) {
|
} else if (action.equals(Broadcast.CONVERSATION_REMOVE)) {
|
||||||
listener.onRemoveConversation(intent.getExtras().getString(Extra.CONVERSATION));
|
listener.onRemoveConversation(intent.getExtras().getString(Extra.CONVERSATION));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,24 +33,24 @@ import android.content.Intent;
|
|||||||
*/
|
*/
|
||||||
public class ServerReceiver extends BroadcastReceiver
|
public class ServerReceiver extends BroadcastReceiver
|
||||||
{
|
{
|
||||||
private ServerListener listener;
|
private ServerListener listener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new server receiver
|
* Create a new server receiver
|
||||||
*
|
*
|
||||||
* @param listener
|
* @param listener
|
||||||
*/
|
*/
|
||||||
public ServerReceiver(ServerListener listener)
|
public ServerReceiver(ServerListener listener)
|
||||||
{
|
{
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On receive broadcast
|
* On receive broadcast
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent)
|
public void onReceive(Context context, Intent intent)
|
||||||
{
|
{
|
||||||
listener.onStatusUpdate();
|
listener.onStatusUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user