Materail design: Floating action button for new email action
This commit breaks automatic builds that pull dependencies from Maven Central,
because com.getbase:floatingactionbutton:1.0.0 has a minSdkVersion of 14. Local
testing indicates the library operates fine on API 10.
Builders will need to pull the source, change the minSdkVersion to 9, and then
run `gradle installArchives` to build and install the library locally. Then add
mavenLocal() to allprojects{repositories{}} in build.gradle.
An issue has been raised requesting official support for API 9+:
https://github.com/futuresimple/android-floating-action-button/issues/11
This commit is contained in:
@@ -29,6 +29,7 @@ dependencies {
|
||||
compile fileTree(dir: 'libs', include: '*.jar')
|
||||
compile 'com.android.support:support-v4:21.0.0'
|
||||
compile 'com.android.support:appcompat-v7:21.0.0'
|
||||
compile 'com.getbase:floatingactionbutton:1.0.0'
|
||||
compile ('com.mcxiaoke.viewpagerindicator:library:2.4.1') {
|
||||
exclude group: 'com.android.support', module: 'support-v4'
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
@@ -63,7 +64,7 @@ public class EmailListFragment extends AuthenticatedListFragment implements
|
||||
private EmailListAdapter mAdapter;
|
||||
private EmailFolder mFolder;
|
||||
|
||||
private MenuItem mNewEmail;
|
||||
private ImageButton mNewEmail;
|
||||
private MenuItem mCheckEmail;
|
||||
|
||||
// The Controller which provides CHOICE_MODE_MULTIPLE_MODAL-like functionality
|
||||
@@ -104,13 +105,24 @@ public class EmailListFragment extends AuthenticatedListFragment implements
|
||||
|
||||
String folderName = getArguments().getString(FOLDER_NAME);
|
||||
mFolder = BoteHelper.getMailFolder(folderName);
|
||||
boolean isInbox = BoteHelper.isInbox(mFolder);
|
||||
|
||||
if (BoteHelper.isInbox(mFolder)) {
|
||||
// Inflate the MultiSwipeRefreshLayout
|
||||
mSwipeRefreshLayout = (MultiSwipeRefreshLayout) inflater.inflate(
|
||||
R.layout.fragment_list_emails, container, false);
|
||||
FrameLayout listContainer = (FrameLayout) mSwipeRefreshLayout.findViewById(R.id.list_container);
|
||||
listContainer.addView(listFragmentView);
|
||||
View v = inflater.inflate(
|
||||
isInbox ? R.layout.fragment_list_emails_with_refresh : R.layout.fragment_list_emails,
|
||||
container, false);
|
||||
FrameLayout listContainer = (FrameLayout) v.findViewById(R.id.list_container);
|
||||
listContainer.addView(listFragmentView);
|
||||
|
||||
mNewEmail = (ImageButton) v.findViewById(R.id.promoted_action);
|
||||
mNewEmail.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
startNewEmail();
|
||||
}
|
||||
});
|
||||
|
||||
if (isInbox) {
|
||||
mSwipeRefreshLayout = (MultiSwipeRefreshLayout) v;
|
||||
|
||||
// Set up the empty view
|
||||
View emptyView = mSwipeRefreshLayout.findViewById(android.R.id.empty);
|
||||
@@ -124,11 +136,9 @@ public class EmailListFragment extends AuthenticatedListFragment implements
|
||||
mSwipeRefreshLayout.setSwipeableChildren(android.R.id.list, android.R.id.empty);
|
||||
mSwipeRefreshLayout.setOnRefreshListener(this);
|
||||
mSwipeRefreshLayout.setRefreshing(I2PBote.getInstance().isCheckingForMail());
|
||||
}
|
||||
|
||||
// Now return the MultiSwipeRefreshLayout as this fragment's content view
|
||||
return mSwipeRefreshLayout;
|
||||
} else
|
||||
return listFragmentView;
|
||||
return v;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -218,7 +228,6 @@ public class EmailListFragment extends AuthenticatedListFragment implements
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
inflater.inflate(R.menu.email_list, menu);
|
||||
mNewEmail = menu.findItem(R.id.action_new_email);
|
||||
mCheckEmail = menu.findItem(R.id.action_check_email);
|
||||
}
|
||||
|
||||
@@ -226,7 +235,7 @@ public class EmailListFragment extends AuthenticatedListFragment implements
|
||||
public void onPrepareOptionsMenu(Menu menu) {
|
||||
super.onPrepareOptionsMenu(menu);
|
||||
boolean passwordRequired = I2PBote.getInstance().isPasswordRequired();
|
||||
mNewEmail.setVisible(!passwordRequired);
|
||||
mNewEmail.setVisibility(passwordRequired ? View.GONE : View.VISIBLE);
|
||||
mCheckEmail.setVisible(mSwipeRefreshLayout != null && !passwordRequired);
|
||||
if (mSwipeRefreshLayout != null)
|
||||
mSwipeRefreshLayout.setEnabled(!passwordRequired);
|
||||
@@ -235,10 +244,6 @@ public class EmailListFragment extends AuthenticatedListFragment implements
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_new_email:
|
||||
startNewEmail();
|
||||
return true;
|
||||
|
||||
case R.id.action_check_email:
|
||||
if (!mSwipeRefreshLayout.isRefreshing()) {
|
||||
mSwipeRefreshLayout.setRefreshing(true);
|
||||
|
||||
@@ -1,30 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<i2p.bote.android.util.MultiSwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/swipe_refresh"
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/list_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/list_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
<ScrollView
|
||||
android:id="@android:id/empty"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/empty_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:text="@string/folder_empty" />
|
||||
</ScrollView>
|
||||
</FrameLayout>
|
||||
|
||||
</i2p.bote.android.util.MultiSwipeRefreshLayout>
|
||||
<com.getbase.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/promoted_action"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginBottom="@dimen/listitem_horizontal_margin"
|
||||
android:layout_marginEnd="@dimen/listitem_horizontal_margin"
|
||||
android:layout_marginRight="@dimen/listitem_horizontal_margin"
|
||||
app:colorNormal="@color/accent"
|
||||
app:colorPressed="@color/accent_dark"
|
||||
app:drawable="@drawable/ic_create_white_24dp" />
|
||||
</RelativeLayout>
|
||||
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<i2p.bote.android.util.MultiSwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/swipe_refresh"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/list_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<ScrollView
|
||||
android:id="@android:id/empty"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/empty_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:text="@string/folder_empty" />
|
||||
</ScrollView>
|
||||
|
||||
<com.getbase.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/promoted_action"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginBottom="@dimen/listitem_horizontal_margin"
|
||||
android:layout_marginEnd="@dimen/listitem_horizontal_margin"
|
||||
android:layout_marginRight="@dimen/listitem_horizontal_margin"
|
||||
app:colorNormal="@color/accent"
|
||||
app:colorPressed="@color/accent_dark"
|
||||
app:drawable="@drawable/ic_create_white_24dp" />
|
||||
</RelativeLayout>
|
||||
|
||||
</i2p.bote.android.util.MultiSwipeRefreshLayout>
|
||||
@@ -2,12 +2,6 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:i2pandroid="http://schemas.android.com/apk/res-auto" >
|
||||
|
||||
<item
|
||||
android:id="@+id/action_new_email"
|
||||
android:icon="@drawable/ic_create_white_24dp"
|
||||
android:title="@string/action_new_email"
|
||||
i2pandroid:showAsAction="ifRoom"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_check_email"
|
||||
android:title="@string/check_email"
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
<color name="primary">#3f51b5</color><!-- Indigo 500 -->
|
||||
<color name="primary_dark">#303f9f</color><!-- Indigo 700 -->
|
||||
<color name="accent">#ffab40</color><!-- Orange A200 -->
|
||||
<color name="accent_dark">#ff9100</color><!-- Orange A400 -->
|
||||
|
||||
<!-- A translucent holo blue -->
|
||||
<color name="translucent_blue">#9033B5E5</color>
|
||||
|
||||
Reference in New Issue
Block a user