Skip to content

Commit

Permalink
Add a floating action button for pause/resume
Browse files Browse the repository at this point in the history
See #29

The doesn't yet toggle the filter.
  • Loading branch information
raatmarien committed Apr 6, 2016
1 parent fe15b6e commit 4f98749
Show file tree
Hide file tree
Showing 15 changed files with 195 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,23 @@
import android.support.v4.app.ActivityCompat;
import android.location.Location;
import android.location.LocationManager;
import android.support.design.widget.FloatingActionButton;
import android.view.ViewTreeObserver;
import android.widget.ListView;

import com.jmstudios.redmoon.R;
import com.jmstudios.redmoon.presenter.ShadesPresenter;
import com.jmstudios.redmoon.activity.ShadesActivity;
import com.jmstudios.redmoon.preference.FilterTimePreference;
import com.jmstudios.redmoon.preference.LocationPreference;
import com.jmstudios.redmoon.model.SettingsModel;

public class ShadesFragment extends PreferenceFragment {
private static final String TAG = "ShadesFragment";
private static final boolean DEBUG = true;

private ShadesPresenter mPresenter;
private int mShadesFabIconResId = -1;
private FloatingActionButton mToggleFab;

// Preferences
private SwitchPreference darkThemePref;
Expand Down Expand Up @@ -231,6 +235,15 @@ public View onCreateView(@NonNull LayoutInflater inflater, final ViewGroup conta
Bundle savedInstanceState) {
final View v = super.onCreateView(inflater, container, savedInstanceState);

mToggleFab = (FloatingActionButton) getActivity().findViewById(R.id.toggle_fab);
mToggleFab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

}
});
updateFabIcon();

return v;
}

Expand All @@ -248,4 +261,16 @@ public void setSwitchOn(boolean on, boolean paused) {
filterSwitch.setChecked(!on);
}
}

private void updateFabIcon() {
SettingsModel settingsModel = ((ShadesActivity) getActivity()).getSettingsModel();
boolean poweredOn = settingsModel.getShadesPowerState();
boolean paused = settingsModel.getShadesPauseState();

if (!poweredOn || paused) {
mToggleFab.setImageResource(R.drawable.fab_start);
} else {
mToggleFab.setImageResource(R.drawable.fab_pause);
}
}
}
Binary file added app/src/main/res/drawable-hdpi/fab_pause.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-hdpi/fab_start.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-mdpi/fab_pause.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-mdpi/fab_start.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xhdpi/fab_pause.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xhdpi/fab_start.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xxhdpi/fab_pause.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xxhdpi/fab_start.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xxxhdpi/fab_pause.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xxxhdpi/fab_start.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions app/src/main/res/layout/activity_shades.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@
android:layout_width="match_parent"
android:layout_height="match_parent" />

<android.support.design.widget.FloatingActionButton
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toggle_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_marginRight="16dp"
android:layout_marginBottom="16dp"
app:backgroundTint="@color/fab_color"
app:fabSize="normal" />
</FrameLayout>


Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@
<color name="color_primary">#FFF44336</color>
<color name="color_primary_dark">#D32F2F</color>
<color name="color_accent">#009688</color>
<color name="fab_color">#FFF44336</color>
</resources>
83 changes: 83 additions & 0 deletions art/fab_pause.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
75 changes: 75 additions & 0 deletions art/fab_start.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4f98749

Please sign in to comment.