Reworked the filter buttons.
This commit is contained in:
parent
11ff7ae10f
commit
44580ec8ca
8 changed files with 62 additions and 106 deletions
|
|
@ -1,13 +1,13 @@
|
|||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 25
|
||||
buildToolsVersion '26.0.3'
|
||||
compileSdkVersion 'android-P'
|
||||
buildToolsVersion '27.0.3'
|
||||
|
||||
defaultConfig {
|
||||
applicationId "org.secuso.privacyfriendlybreakreminder"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 25
|
||||
targetSdkVersion 27
|
||||
versionCode 3
|
||||
versionName "2.1"
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
|
|
@ -37,16 +37,16 @@ repositories {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
compile fileTree(include: ['*.jar'], dir: 'libs')
|
||||
compile 'com.android.support:appcompat-v7:25.4.0'
|
||||
compile 'com.android.support:design:25.4.0'
|
||||
compile 'com.github.bumptech.glide:glide:4.0.0'
|
||||
compile 'com.android.support:support-v4:25.4.0'
|
||||
compile 'com.android.support:support-annotations:27.1.1'
|
||||
compile 'com.android.support:cardview-v7:25.4.0'
|
||||
compile 'com.android.support.constraint:constraint-layout:1.1.0'
|
||||
compile 'com.nex3z:flow-layout:1.0.0'
|
||||
compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:2.0.1'
|
||||
testCompile 'junit:junit:4.12'
|
||||
compile 'com.shawnlin:number-picker:2.4.4' // https://github.com/ShawnLin013/NumberPicker
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
|
||||
implementation 'com.android.support:design:28.0.0-alpha1'
|
||||
implementation 'com.github.bumptech.glide:glide:4.0.0'
|
||||
implementation 'com.android.support:support-v4:28.0.0-alpha1'
|
||||
implementation 'com.android.support:support-annotations:27.1.1'
|
||||
implementation 'com.android.support:cardview-v7:28.0.0-alpha1'
|
||||
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
|
||||
implementation 'com.nex3z:flow-layout:1.0.0'
|
||||
implementation 'com.readystatesoftware.sqliteasset:sqliteassethelper:2.0.1'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
implementation 'com.shawnlin:number-picker:2.4.4' // https://github.com/ShawnLin013/NumberPicker
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,38 +3,31 @@ package org.secuso.privacyfriendlybreakreminder.activities;
|
|||
import android.content.Intent;
|
||||
import android.os.PersistableBundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.chip.Chip;
|
||||
import android.support.design.chip.ChipGroup;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.util.Pair;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.util.SortedList;
|
||||
import android.support.v7.widget.CardView;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.ToggleButton;
|
||||
|
||||
import org.secuso.privacyfriendlybreakreminder.R;
|
||||
import org.secuso.privacyfriendlybreakreminder.activities.adapter.ExerciseAdapter;
|
||||
import org.secuso.privacyfriendlybreakreminder.activities.helper.IExerciseTimeUpdateable;
|
||||
import org.secuso.privacyfriendlybreakreminder.database.SQLiteHelper;
|
||||
import org.secuso.privacyfriendlybreakreminder.database.data.Exercise;
|
||||
import com.nex3z.flowlayout.FlowLayout;
|
||||
import org.secuso.privacyfriendlybreakreminder.exercises.ExerciseLocale;
|
||||
import org.secuso.privacyfriendlybreakreminder.exercises.ExerciseSections;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
|
||||
import static org.secuso.privacyfriendlybreakreminder.activities.adapter.ExerciseAdapter.ID_COMPARATOR;
|
||||
|
||||
/**
|
||||
|
|
@ -49,14 +42,14 @@ public class ChooseExerciseActivity extends AppCompatActivity implements IExerci
|
|||
|
||||
public static final String EXTRA_SELECTED_EXERCISES = TAG+".EXTRA_SELECTED_EXERCISES";
|
||||
|
||||
FlowLayout filterButtonLayout;
|
||||
ChipGroup filterButtonLayout;
|
||||
RecyclerView exerciseList;
|
||||
TextView exerciseSetTimeText;
|
||||
|
||||
ExerciseAdapter exerciseAdapter;
|
||||
SQLiteHelper databaseHelper;
|
||||
|
||||
List<ToggleButton> buttons;
|
||||
List<Chip> buttons;
|
||||
boolean[] buttonStates;
|
||||
|
||||
@Override
|
||||
|
|
@ -90,7 +83,7 @@ public class ChooseExerciseActivity extends AppCompatActivity implements IExerci
|
|||
private void initResources() {
|
||||
databaseHelper = new SQLiteHelper(this);
|
||||
|
||||
filterButtonLayout = (FlowLayout) findViewById(R.id.layout_filter_buttons);
|
||||
filterButtonLayout = (ChipGroup) findViewById(R.id.layout_filter_buttons);
|
||||
exerciseList = (RecyclerView) findViewById(R.id.exercise_list);
|
||||
exerciseAdapter = new ExerciseAdapter(this, ID_COMPARATOR, this);
|
||||
exerciseAdapter.showCheckboxes(true);
|
||||
|
|
@ -99,25 +92,22 @@ public class ChooseExerciseActivity extends AppCompatActivity implements IExerci
|
|||
exerciseList.setLayoutManager(gridLayout);
|
||||
exerciseList.setAdapter(exerciseAdapter);
|
||||
|
||||
filterButtonLayout.removeAllViews();
|
||||
|
||||
final List<ExerciseSections> sections = ExerciseSections.getSectionList();
|
||||
buttonStates = new boolean[sections.size()];
|
||||
buttons = new ArrayList<>(sections.size());
|
||||
buttons = new ArrayList<Chip>(sections.size());
|
||||
|
||||
for(int i = 0; i < sections.size(); ++i) {
|
||||
ExerciseSections section = sections.get(i);
|
||||
|
||||
View view = LayoutInflater.from(this).inflate(R.layout.layout_section_filter_button, null, false);
|
||||
ToggleButton button = (ToggleButton) view.findViewById(R.id.button);
|
||||
|
||||
String sectionText = section.getLocalName(this);
|
||||
|
||||
Chip button = new Chip(this);
|
||||
|
||||
button.setCheckable(true);
|
||||
button.setClickable(true);
|
||||
button.setChecked(false);
|
||||
button.setTextOff(sectionText);
|
||||
button.setTextOn(sectionText);
|
||||
button.setText(sectionText);
|
||||
button.setElegantTextHeight(true);
|
||||
button.setChipText(sectionText);
|
||||
button.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
|
@ -136,7 +126,7 @@ public class ChooseExerciseActivity extends AppCompatActivity implements IExerci
|
|||
});
|
||||
|
||||
buttons.add(button);
|
||||
filterButtonLayout.addView(view);
|
||||
filterButtonLayout.addView(button);
|
||||
}
|
||||
|
||||
exerciseSetTimeText = (TextView) findViewById(R.id.exercise_set_time);
|
||||
|
|
|
|||
|
|
@ -6,20 +6,21 @@
|
|||
android:layout_height="match_parent"
|
||||
tools:context="org.secuso.privacyfriendlybreakreminder.activities.ChooseExerciseActivity">
|
||||
|
||||
<com.nex3z.flowlayout.FlowLayout
|
||||
<android.support.design.chip.ChipGroup
|
||||
android:id="@+id/layout_filter_buttons"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:orientation="vertical"
|
||||
app:flChildSpacing="8dp"
|
||||
app:flChildSpacingForLastRow="align"
|
||||
app:flRowSpacing="8dp"
|
||||
app:chipSpacing="4dp"
|
||||
app:singleSelection="true"
|
||||
app:singleLine="false"
|
||||
app:layout_constraintEnd_toStartOf="@+id/exercise_set_time"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
</android.support.design.chip.ChipGroup>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/exercise_set_time"
|
||||
|
|
@ -43,16 +44,15 @@
|
|||
android:id="@+id/exercise_list"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="4dp"
|
||||
android:layout_marginTop="8dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/layout_filter_buttons"
|
||||
app:layout_constraintVertical_bias="0.0"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="4dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="4dp" />
|
||||
tools:listitem="@layout/layout_exercise_grid_item" />
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
|
|
|
|||
|
|
@ -1,26 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<android.support.design.chip.Chip
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ToggleButton
|
||||
android:id="@+id/button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="0dp"
|
||||
android:padding="0dp"
|
||||
android:background="@drawable/button_section"
|
||||
android:paddingLeft="1dp"
|
||||
android:paddingRight="1dp"
|
||||
android:text="Section"
|
||||
android:minWidth="65dp"
|
||||
android:minHeight="45dp"
|
||||
android:textColor="@drawable/button_section_textcolor"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Section" />
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
<resources>
|
||||
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
<item name="android:timePickerStyle">@style/TimePickerDialogStyle</item>
|
||||
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.NoActionBar">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
|
||||
<!-- <item name="android:statusBarColor">@android:color/transparent</item> -->
|
||||
</style>
|
||||
|
||||
<style name="TimePickerDialogStyle" parent="@android:style/Widget.Material.Light.TimePicker">
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
<item name="android:timePickerMode">clock</item>
|
||||
<item name="android:headerBackground">@color/white</item>
|
||||
<item name="android:headerTimeTextAppearance">@style/TextAppearance.TimePickerDialogStyle.TimeLabel</item>
|
||||
</style>
|
||||
|
||||
<style name="TextAppearance.TimePickerDialogStyle.TimeLabel" parent="@android:style/TextAppearance.Material">
|
||||
<item name="android:textSize">60sp</item> <!-- from -->
|
||||
<item name="android:textColor">@color/colorPrimary</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
|
@ -8,6 +8,7 @@
|
|||
<item name="colorAccent">@color/colorAccent</item>
|
||||
|
||||
<item name="android:alertDialogTheme">@style/AppTheme.AlertDialog</item>
|
||||
<item name="android:timePickerStyle">@style/TimePickerDialogStyle</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.Dialog" parent="Theme.AppCompat.Light.Dialog">
|
||||
|
|
@ -24,6 +25,7 @@
|
|||
<style name="AppTheme.NoActionBar">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.NumberPicker" parent="AppTheme">
|
||||
|
|
@ -42,4 +44,16 @@
|
|||
<item name="android:windowNoTitle">true</item>
|
||||
</style>
|
||||
|
||||
<style name="TimePickerDialogStyle" parent="@android:style/Widget.Material.Light.TimePicker">
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
<item name="android:timePickerMode">clock</item>
|
||||
<item name="android:headerBackground">@color/white</item>
|
||||
<item name="android:headerTimeTextAppearance">@style/TextAppearance.TimePickerDialogStyle.TimeLabel</item>
|
||||
</style>
|
||||
|
||||
<style name="TextAppearance.TimePickerDialogStyle.TimeLabel" parent="@android:style/TextAppearance.Material">
|
||||
<item name="android:textSize">60sp</item> <!-- from -->
|
||||
<item name="android:textColor">@color/colorPrimary</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ buildscript {
|
|||
google()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.0.1'
|
||||
classpath 'com.android.tools.build:gradle:3.1.2'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
|
|
|
|||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
|
@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
|||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue