mirror of
https://github.com/moparisthebest/Yaaic
synced 2024-11-13 20:45:12 -05:00
Refactor AddServerActivity to use Toolbar API.
This commit is contained in:
parent
b1fe1b09a0
commit
0e0b2bb199
@ -20,11 +20,12 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.yaaic.activity;
|
||||
|
||||
import android.app.ActionBar;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
@ -56,7 +57,7 @@ import java.util.regex.Pattern;
|
||||
*
|
||||
* @author Sebastian Kaspari <sebastian@yaaic.org>
|
||||
*/
|
||||
public class AddServerActivity extends Activity implements OnClickListener
|
||||
public class AddServerActivity extends ActionBarActivity implements OnClickListener
|
||||
{
|
||||
private static final int REQUEST_CODE_CHANNELS = 1;
|
||||
private static final int REQUEST_CODE_COMMANDS = 2;
|
||||
@ -77,9 +78,12 @@ public class AddServerActivity extends Activity implements OnClickListener
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.serveradd);
|
||||
setContentView(R.layout.activity_add_server);
|
||||
|
||||
ActionBar actionBar = getActionBar();
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
authentication = new Authentication();
|
||||
@ -172,12 +176,8 @@ public class AddServerActivity extends Activity implements OnClickListener
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* On menu item selected
|
||||
*/
|
||||
@Override
|
||||
public boolean onMenuItemSelected(int featureId, MenuItem item)
|
||||
{
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.save:
|
||||
save();
|
||||
@ -185,10 +185,10 @@ public class AddServerActivity extends Activity implements OnClickListener
|
||||
|
||||
case android.R.id.home:
|
||||
finish();
|
||||
break;
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onMenuItemSelected(featureId, item);
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -321,9 +321,6 @@ public class Message
|
||||
*/
|
||||
public TextView renderTextView(Context context)
|
||||
{
|
||||
// XXX: We should not read settings here ALWAYS for EVERY textview
|
||||
Settings settings = new Settings(context);
|
||||
|
||||
TextView canvas = new TextView(context);
|
||||
|
||||
canvas.setAutoLinkMask(Linkify.ALL);
|
||||
|
242
app/src/main/res/layout/activity_add_server.xml
Normal file
242
app/src/main/res/layout/activity_add_server.xml
Normal file
@ -0,0 +1,242 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?><!--
|
||||
Yaaic - Yet Another Android IRC Client
|
||||
|
||||
Copyright 2009-2013 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/>.
|
||||
-->
|
||||
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/drawer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<include layout="@layout/item_toolbar" />
|
||||
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:scrollbarStyle="outsideInset">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
style="?android:attr/listSeparatorTextViewStyle"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="3dip"
|
||||
android:text="@string/server" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/server_title" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/title"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@string/server_title"
|
||||
android:singleLine="true" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/server_host" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/host"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@string/server_host"
|
||||
android:inputType="textNoSuggestions"
|
||||
android:singleLine="true" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/server_port" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/port"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@string/server_port"
|
||||
android:maxLength="5"
|
||||
android:minEms="6"
|
||||
android:numeric="integer"
|
||||
android:singleLine="true"
|
||||
android:text="6667" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/server_password" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/password"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@string/server_password"
|
||||
android:maxEms="10"
|
||||
android:minEms="10"
|
||||
android:password="true"
|
||||
android:singleLine="true" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/autoconnect"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@string/server_port"
|
||||
android:text="@string/server_port"
|
||||
android:visibility="gone" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/useSSL"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@string/server_useSSL"
|
||||
android:text="@string/server_useSSL" />
|
||||
<!-- ############################################################################ -->
|
||||
<TextView
|
||||
style="?android:attr/listSeparatorTextViewStyle"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="3dip"
|
||||
android:text="@string/user" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/nickname" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/nickname"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@string/nickname"
|
||||
android:singleLine="true" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/aliases"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/aliases" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/ident" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/ident"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@string/ident"
|
||||
android:singleLine="true"
|
||||
android:text="yaaic" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/realname" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/realname"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@string/realname"
|
||||
android:singleLine="true"
|
||||
android:text="" />
|
||||
<!-- ############################################################################ -->
|
||||
<TextView
|
||||
style="?android:attr/listSeparatorTextViewStyle"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="3dip"
|
||||
android:text="@string/on_connect" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/authentication"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/authentication" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/channels"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/channels" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/commands"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/commands" />
|
||||
<!-- ############################################################################ -->
|
||||
<TextView
|
||||
style="?android:attr/listSeparatorTextViewStyle"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="3dip"
|
||||
android:text="@string/preferences" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/charset" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/charset"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:prompt="@string/select_charset" />
|
||||
<!-- ############################################################################ -->
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingTop="10dp">
|
||||
|
||||
<Button
|
||||
android:id="@+id/add"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/server_save" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/cancel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0"
|
||||
android:text="@string/action_cancel" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
</LinearLayout>
|
||||
|
||||
<include layout="@layout/item_drawer" />
|
||||
|
||||
</android.support.v4.widget.DrawerLayout>
|
@ -1,200 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Yaaic - Yet Another Android IRC Client
|
||||
|
||||
Copyright 2009-2013 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/>.
|
||||
-->
|
||||
<ScrollView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:scrollbarStyle="outsideInset">
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<TextView
|
||||
android:text="@string/server"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="3dip"
|
||||
style="?android:attr/listSeparatorTextViewStyle" />
|
||||
<TextView
|
||||
android:text="@string/server_title"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
<EditText
|
||||
android:id="@+id/title"
|
||||
android:contentDescription="@string/server_title"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true" />
|
||||
<TextView
|
||||
android:text="@string/server_host"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
<EditText
|
||||
android:id="@+id/host"
|
||||
android:contentDescription="@string/server_host"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:inputType="textNoSuggestions" />
|
||||
<TextView
|
||||
android:text="@string/server_port"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
<EditText
|
||||
android:id="@+id/port"
|
||||
android:contentDescription="@string/server_port"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:minEms="6"
|
||||
android:text="6667"
|
||||
android:numeric="integer"
|
||||
android:maxLength="5" />
|
||||
<TextView
|
||||
android:text="@string/server_password"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
<EditText
|
||||
android:id="@+id/password"
|
||||
android:contentDescription="@string/server_password"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:password="true"
|
||||
android:minEms="10"
|
||||
android:maxEms="10" />
|
||||
<CheckBox
|
||||
android:id="@+id/autoconnect"
|
||||
android:contentDescription="@string/server_port"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/server_port"
|
||||
android:visibility="gone" />
|
||||
<CheckBox
|
||||
android:id="@+id/useSSL"
|
||||
android:contentDescription="@string/server_useSSL"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/server_useSSL" />
|
||||
<!-- ############################################################################ -->
|
||||
<TextView
|
||||
android:text="@string/user"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="3dip"
|
||||
style="?android:attr/listSeparatorTextViewStyle" />
|
||||
<TextView
|
||||
android:text="@string/nickname"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
<EditText
|
||||
android:id="@+id/nickname"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:contentDescription="@string/nickname" />
|
||||
<Button
|
||||
android:id="@+id/aliases"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/aliases" />
|
||||
<TextView
|
||||
android:text="@string/ident"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
<EditText
|
||||
android:id="@+id/ident"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="yaaic"
|
||||
android:contentDescription="@string/ident"
|
||||
android:singleLine="true" />
|
||||
<TextView
|
||||
android:text="@string/realname"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
<EditText
|
||||
android:id="@+id/realname"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text=""
|
||||
android:contentDescription="@string/realname"
|
||||
android:singleLine="true" />
|
||||
<!-- ############################################################################ -->
|
||||
<TextView
|
||||
android:text="@string/on_connect"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="3dip"
|
||||
style="?android:attr/listSeparatorTextViewStyle" />
|
||||
<Button
|
||||
android:id="@+id/authentication"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/authentication" />
|
||||
<Button
|
||||
android:id="@+id/channels"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/channels" />
|
||||
<Button
|
||||
android:id="@+id/commands"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/commands" />
|
||||
<!-- ############################################################################ -->
|
||||
<TextView
|
||||
android:text="@string/preferences"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="3dip"
|
||||
style="?android:attr/listSeparatorTextViewStyle" />
|
||||
<TextView
|
||||
android:text="@string/charset"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
<Spinner
|
||||
android:id="@+id/charset"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:prompt="@string/select_charset" />
|
||||
<!-- ############################################################################ -->
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="10dp">
|
||||
<Button
|
||||
android:id="@+id/add"
|
||||
android:text="@string/server_save"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1" />
|
||||
<Button
|
||||
android:id="@+id/cancel"
|
||||
android:text="@string/action_cancel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
@ -24,5 +24,5 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
|
||||
android:id="@+id/save"
|
||||
android:title="@string/server_save"
|
||||
android:icon="@drawable/actionbar_save"
|
||||
android:showAsAction="ifRoom|withText" />
|
||||
android:showAsAction="always" />
|
||||
</menu>
|
Loading…
Reference in New Issue
Block a user