1
0
mirror of https://github.com/moparisthebest/Yaaic synced 2024-11-25 18:32:15 -05:00

Settings Activity and co.

This commit is contained in:
Sebastian Kaspari 2010-03-13 19:56:32 +01:00
parent 47b3628853
commit 7183c1c06c
9 changed files with 121 additions and 3 deletions

View File

@ -44,6 +44,10 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
android:label="@string/about_label"
android:theme="@android:style/Theme.Dialog">
</activity>
<activity
android:name=".view.SettingsActivity"
android:label="@string/settings_label">
</activity>
<service android:name=".irc.IRCService"></service>
</application>

View File

@ -24,6 +24,10 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
android:id="@+id/add"
android:title="@string/add_server_menu"
android:icon="@android:drawable/ic_menu_add" />
<item
android:id="@+id/settings"
android:title="@string/settings_menu"
android:icon="@android:drawable/ic_menu_preferences" />
<item
android:id="@+id/about"
android:title="@string/about_menu"

11
res/values/settings.xml Normal file
View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="key_show_timestamp">show_timestamp</string>
<string name="default_show_timestamp">false</string>
<string name="key_show_icons">show_icons</string>
<string name="default_show_icons">true</string>
<string name="key_show_colors">show_colors</string>
<string name="default_show_colors">true</string>
</resources>

View File

@ -7,6 +7,7 @@
<string name="app_copyright">(C) 2009-2010 Sebastian Kaspari</string>
<string name="add_server_menu">Add server</string>
<string name="settings_menu">Settings</string>
<string name="about_menu">About</string>
<string name="add_server_label">Add new server</string>
@ -34,4 +35,6 @@
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.
</string>
<string name="settings_label">Settings</string>
</resources>

42
res/xml/preferences.xml Normal file
View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Yaaic - Yet Another Android IRC Client
Copyright 2009-2010 Sebastian Kaspari
This file is part of Yaaic.
Yaaic is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Yaaic is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
-->
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:title="Chat">
<CheckBoxPreference
android:title="Show icons"
android:summary="Show icons to highlight special events"
android:key="@string/key_show_icons"
android:defaultValue="" />
<CheckBoxPreference
android:title="Show colors"
android:summary="Show colors to highlight special events"
android:key="@string/key_show_colors"
android:defaultValue="@string/default_show_colors" />
<CheckBoxPreference
android:title="Show timestamp"
android:summary="Prefix all messages with a timestamp"
android:key="@string/key_show_timestamp"
android:defaultValue="@string/default_show_timestamp" />
</PreferenceCategory>
</PreferenceScreen>

View File

@ -108,15 +108,18 @@ public class Message {
*/
public SpannableString render(Context context)
{
Settings settings = new Settings(context);
if (canvas == null) {
String prefix = hasIcon() ? " " : "";
String prefix = hasIcon() && settings.showIcons() ? " " : "";
canvas = new SpannableString(prefix + text);
if (hasIcon()) {
if (hasIcon() && settings.showIcons()) {
Drawable drawable = context.getResources().getDrawable(icon);
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
canvas.setSpan(new ImageSpan(drawable, ImageSpan.ALIGN_BOTTOM), 0, 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
if (color != -1) {
if (color != -1 && settings.showTimestamp()) {
canvas.setSpan(new ForegroundColorSpan(color), 0, canvas.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
}

View File

@ -44,6 +44,9 @@ public class AddServerActivity extends Activity implements OnClickListener
{
public static final String TAG = "Yaaic/AddServerActivity";
/**
* On create
*/
@Override
public void onCreate(Bundle savedInstanceState)
{

View File

@ -207,6 +207,9 @@ public class ServersActivity extends ListActivity implements ServiceConnection,
case R.id.about:
startActivity(new Intent(this, AboutActivity.class));
break;
case R.id.settings:
startActivity(new Intent(this, SettingsActivity.class));
break;
}
return true;

View File

@ -0,0 +1,45 @@
/*
Yaaic - Yet Another Android IRC Client
Copyright 2009-2010 Sebastian Kaspari
This file is part of Yaaic.
Yaaic is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Yaaic is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
*/
package org.yaaic.view;
import org.yaaic.R;
import android.os.Bundle;
import android.preference.PreferenceActivity;
/**
* Settings
*
* @author Sebastian Kaspari <sebastian@yaaic.org>
*/
public class SettingsActivity extends PreferenceActivity
{
/**
* On create
*/
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
}
}