Commit ccfecf7e authored by Grigory Fedorov's avatar Grigory Fedorov

Floating Action Button used in ContactEditor (group add)

github.com/makovkastar/FloatingActionButton library used.
parent b7f8e945
...@@ -26,5 +26,6 @@ dependencies { ...@@ -26,5 +26,6 @@ dependencies {
compile 'com.android.support:appcompat-v7:22.0.0' compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.android.support:support-v13:22.0.0' compile 'com.android.support:support-v13:22.0.0'
compile 'com.github.ksoichiro:android-observablescrollview:1.5.0' compile 'com.github.ksoichiro:android-observablescrollview:1.5.0'
compile 'com.melnykov:floatingactionbutton:1.2.0'
compile project('otr4j') compile project('otr4j')
} }
...@@ -18,9 +18,12 @@ import android.content.Context; ...@@ -18,9 +18,12 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.EditText; import android.widget.EditText;
import android.widget.ListView;
import com.melnykov.fab.FloatingActionButton;
import com.xabber.android.data.Application; import com.xabber.android.data.Application;
import com.xabber.android.data.NetworkException; import com.xabber.android.data.NetworkException;
import com.xabber.android.data.account.AccountManager; import com.xabber.android.data.account.AccountManager;
...@@ -30,6 +33,7 @@ import com.xabber.android.data.intent.EntityIntentBuilder; ...@@ -30,6 +33,7 @@ import com.xabber.android.data.intent.EntityIntentBuilder;
import com.xabber.android.data.roster.AbstractContact; import com.xabber.android.data.roster.AbstractContact;
import com.xabber.android.data.roster.OnContactChangedListener; import com.xabber.android.data.roster.OnContactChangedListener;
import com.xabber.android.data.roster.RosterManager; import com.xabber.android.data.roster.RosterManager;
import com.xabber.android.ui.dialog.GroupAddDialogFragment;
import com.xabber.android.ui.helper.ContactTitleActionBarInflater; import com.xabber.android.ui.helper.ContactTitleActionBarInflater;
import com.xabber.androiddev.R; import com.xabber.androiddev.R;
import com.xabber.xmpp.address.Jid; import com.xabber.xmpp.address.Jid;
...@@ -37,7 +41,7 @@ import com.xabber.xmpp.address.Jid; ...@@ -37,7 +41,7 @@ import com.xabber.xmpp.address.Jid;
import java.util.Collection; import java.util.Collection;
public class ContactEditor extends GroupListActivity implements public class ContactEditor extends GroupListActivity implements
OnContactChangedListener, OnAccountChangedListener { OnContactChangedListener, OnAccountChangedListener, View.OnClickListener {
private String account; private String account;
private String user; private String user;
...@@ -60,6 +64,11 @@ public class ContactEditor extends GroupListActivity implements ...@@ -60,6 +64,11 @@ public class ContactEditor extends GroupListActivity implements
Application.getInstance().onError(R.string.ENTRY_IS_NOT_FOUND); Application.getInstance().onError(R.string.ENTRY_IS_NOT_FOUND);
finish(); finish();
} }
ListView listView = (ListView) findViewById(android.R.id.list);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.attachToListView(listView);
fab.setOnClickListener(this);
} }
@Override @Override
...@@ -131,4 +140,13 @@ public class ContactEditor extends GroupListActivity implements ...@@ -131,4 +140,13 @@ public class ContactEditor extends GroupListActivity implements
return EntityIntentBuilder.getUser(intent); return EntityIntentBuilder.getUser(intent);
} }
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.fab:
showGroupAddDialog();
return;
}
}
} }
...@@ -138,7 +138,7 @@ public abstract class GroupListActivity extends ManagedListActivity implements O ...@@ -138,7 +138,7 @@ public abstract class GroupListActivity extends ManagedListActivity implements O
return false; return false;
} }
private void showGroupAddDialog() { protected void showGroupAddDialog() {
GroupAddDialogFragment.newInstance(getGroups()).show(getFragmentManager(), "GROUP-ADD"); GroupAddDialogFragment.newInstance(getGroups()).show(getFragmentManager(), "GROUP-ADD");
} }
......
...@@ -61,7 +61,7 @@ public abstract class BaseContactInflater { ...@@ -61,7 +61,7 @@ public abstract class BaseContactInflater {
this.activity = activity; this.activity = activity;
layoutInflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); layoutInflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
Bitmap bitmap = BitmapFactory.decodeResource(activity.getResources(), R.drawable.shadow); Bitmap bitmap = BitmapFactory.decodeResource(activity.getResources(), R.drawable.contact_shadow);
shadowDrawable = new BitmapDrawable(activity.getResources(), bitmap); shadowDrawable = new BitmapDrawable(activity.getResources(), bitmap);
shadowDrawable.setTileModeXY(TileMode.REPEAT, TileMode.REPEAT); shadowDrawable.setTileModeXY(TileMode.REPEAT, TileMode.REPEAT);
......
...@@ -100,7 +100,7 @@ ...@@ -100,7 +100,7 @@
android:id="@+id/shadow" android:id="@+id/shadow"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/contact_list_item_height" android:layout_height="@dimen/contact_list_item_height"
android:background="@drawable/shadow" android:background="@drawable/contact_shadow"
android:visibility="gone" android:visibility="gone"
/> />
</RelativeLayout> </RelativeLayout>
...@@ -12,14 +12,16 @@ ...@@ -12,14 +12,16 @@
You should have received a copy of the GNU General Public License, You should have received a copy of the GNU General Public License,
along with this program. If not, see http://www.gnu.org/licenses/. along with this program. If not, see http://www.gnu.org/licenses/.
--> -->
<LinearLayout <RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" xmlns:fab="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
> >
<include layout="@layout/toolbar_default"/> <include layout="@layout/toolbar_default"
android:id="@+id/toolbar_default"
/>
<TextView <TextView
android:text="@string/contact_group" android:text="@string/contact_group"
...@@ -29,13 +31,32 @@ ...@@ -29,13 +31,32 @@
android:paddingBottom="2dip" android:paddingBottom="2dip"
android:paddingLeft="2dip" android:paddingLeft="2dip"
android:paddingRight="2dip" android:paddingRight="2dip"
android:id="@+id/edit_groups_title"
android:layout_below="@+id/toolbar_default"
/> />
<ListView <ListView
android:id="@android:id/list" android:id="@android:id/list"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
android:paddingLeft="6dip" android:paddingLeft="8dp"
android:paddingStart="8dp"
android:layout_below="@+id/edit_groups_title"
/>
<com.melnykov.fab.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_margin="16dp"
android:src="@drawable/ic_add_white_24dp"
fab:fab_colorNormal="@color/red_500"
fab:fab_colorPressed="@color/red_700"
fab:fab_colorRipple="@color/red_300"
/> />
</LinearLayout>
\ No newline at end of file </RelativeLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment