From 0e0b2bb1993d968e0832a7bc516f14a40693719c Mon Sep 17 00:00:00 2001 From: Sebastian Kaspari Date: Wed, 25 Mar 2015 22:23:56 +0100 Subject: [PATCH] Refactor AddServerActivity to use Toolbar API. --- .../org/yaaic/activity/AddServerActivity.java | 24 +- .../main/java/org/yaaic/model/Message.java | 3 - .../main/res/layout/activity_add_server.xml | 242 ++++++++++++++++++ app/src/main/res/layout/serveradd.xml | 200 --------------- app/src/main/res/menu/addserver.xml | 2 +- 5 files changed, 255 insertions(+), 216 deletions(-) create mode 100644 app/src/main/res/layout/activity_add_server.xml delete mode 100644 app/src/main/res/layout/serveradd.xml diff --git a/app/src/main/java/org/yaaic/activity/AddServerActivity.java b/app/src/main/java/org/yaaic/activity/AddServerActivity.java index c89462e..7a82092 100644 --- a/app/src/main/java/org/yaaic/activity/AddServerActivity.java +++ b/app/src/main/java/org/yaaic/activity/AddServerActivity.java @@ -20,11 +20,12 @@ along with Yaaic. If not, see . */ 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 */ -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); } /** diff --git a/app/src/main/java/org/yaaic/model/Message.java b/app/src/main/java/org/yaaic/model/Message.java index 533201f..067707a 100644 --- a/app/src/main/java/org/yaaic/model/Message.java +++ b/app/src/main/java/org/yaaic/model/Message.java @@ -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); diff --git a/app/src/main/res/layout/activity_add_server.xml b/app/src/main/res/layout/activity_add_server.xml new file mode 100644 index 0000000..287cf3a --- /dev/null +++ b/app/src/main/res/layout/activity_add_server.xml @@ -0,0 +1,242 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +