From d299dd34eda5c98a8c14a86c4bdcf0dc3ca267f8 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Tue, 7 Mar 2017 01:38:22 +0100 Subject: [PATCH] Floating action button for toot compose --- .../com/keylesspalace/tusky/MainActivity.java | 16 +++++++++++----- app/src/main/res/drawable/ic_create_24dp.xml | 9 +++++++++ app/src/main/res/layout/activity_main.xml | 14 ++++++++++---- app/src/main/res/menu/main_toolbar.xml | 6 ------ 4 files changed, 30 insertions(+), 15 deletions(-) create mode 100644 app/src/main/res/drawable/ic_create_24dp.xml diff --git a/app/src/main/java/com/keylesspalace/tusky/MainActivity.java b/app/src/main/java/com/keylesspalace/tusky/MainActivity.java index 50c0463a..899bd1a3 100644 --- a/app/src/main/java/com/keylesspalace/tusky/MainActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/MainActivity.java @@ -23,12 +23,14 @@ import android.content.SharedPreferences; import android.graphics.drawable.Drawable; import android.os.SystemClock; import android.preference.PreferenceManager; +import android.support.design.widget.FloatingActionButton; import android.support.design.widget.TabLayout; import android.support.v4.view.ViewPager; import android.os.Bundle; import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuItem; +import android.view.View; import com.android.volley.AuthFailureError; import com.android.volley.Request; @@ -62,6 +64,15 @@ public class MainActivity extends BaseActivity { Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); + FloatingActionButton floatingBtn = (FloatingActionButton) findViewById(R.id.floating_btn); + floatingBtn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(getApplicationContext(), ComposeActivity.class); + startActivity(intent); + } + }); + // Setup the tabs and timeline pager. TimelinePagerAdapter adapter = new TimelinePagerAdapter(getSupportFragmentManager()); String[] pageTitles = { @@ -170,11 +181,6 @@ public class MainActivity extends BaseActivity { @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { - case R.id.action_compose: { - Intent intent = new Intent(this, ComposeActivity.class); - startActivity(intent); - return true; - } case R.id.action_view_profile: { Intent intent = new Intent(this, AccountActivity.class); intent.putExtra("id", loggedInAccountId); diff --git a/app/src/main/res/drawable/ic_create_24dp.xml b/app/src/main/res/drawable/ic_create_24dp.xml new file mode 100644 index 00000000..fb323492 --- /dev/null +++ b/app/src/main/res/drawable/ic_create_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 2da08be8..031b9ccf 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -1,5 +1,5 @@ - @@ -54,14 +55,19 @@ - - - \ No newline at end of file + + \ No newline at end of file diff --git a/app/src/main/res/menu/main_toolbar.xml b/app/src/main/res/menu/main_toolbar.xml index 8ed161a5..2517ee5d 100644 --- a/app/src/main/res/menu/main_toolbar.xml +++ b/app/src/main/res/menu/main_toolbar.xml @@ -3,12 +3,6 @@ xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> - -