Add no tags toggle
This commit is contained in:
parent
43907a172e
commit
84c0674e1e
6 changed files with 54 additions and 2 deletions
|
@ -603,7 +603,9 @@ public class MainActivity extends BaseActivity
|
|||
tagsToggle.setDrawerIndicatorEnabled(true);
|
||||
tagsDrawerLayout.addDrawerListener(tagsToggle);
|
||||
|
||||
final CheckedTextView noTagsButton = (CheckedTextView)findViewById(R.id.no_tags_entries);
|
||||
CheckedTextView allTagsButton = (CheckedTextView)findViewById(R.id.all_tags_in_drawer);
|
||||
|
||||
allTagsButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
@ -616,6 +618,8 @@ public class MainActivity extends BaseActivity
|
|||
CheckedTextView childCheckBox = (CheckedTextView)tagsDrawerListView.getChildAt(i);
|
||||
childCheckBox.setChecked(checkedTextView.isChecked());
|
||||
}
|
||||
noTagsButton.setChecked(checkedTextView.isChecked());
|
||||
settings.setNoTagsToggle(noTagsButton.isChecked());
|
||||
|
||||
if(checkedTextView.isChecked()) {
|
||||
adapter.filterByTags(adapter.getTags());
|
||||
|
@ -626,6 +630,18 @@ public class MainActivity extends BaseActivity
|
|||
});
|
||||
allTagsButton.setChecked(settings.getAllTagsToggle());
|
||||
|
||||
noTagsButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
CheckedTextView checkedTextView = ((CheckedTextView)view);
|
||||
checkedTextView.setChecked(!checkedTextView.isChecked());
|
||||
|
||||
settings.setNoTagsToggle(checkedTextView.isChecked());
|
||||
adapter.filterByTags(adapter.getTags());
|
||||
}
|
||||
});
|
||||
noTagsButton.setChecked(settings.getNoTagsToggle());
|
||||
|
||||
tagsDrawerListView.setAdapter(tagsDrawerAdapter);
|
||||
|
||||
tagsDrawerListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
|
|
|
@ -294,6 +294,14 @@ public class Settings {
|
|||
setBoolean(R.string.settings_key_all_tags_toggle, value);
|
||||
}
|
||||
|
||||
public boolean getNoTagsToggle() {
|
||||
return getBoolean(R.string.settings_key_no_tags_toggle, true);
|
||||
}
|
||||
|
||||
public void setNoTagsToggle(Boolean value) {
|
||||
setBoolean(R.string.settings_key_no_tags_toggle, value);
|
||||
}
|
||||
|
||||
public boolean getTagToggle(String tag) {
|
||||
//The tag toggle holds tags that are unchecked in order to default to checked.
|
||||
Set<String> toggledTags = getStringSet(R.string.settings_key_tags_toggles, new HashSet<String>());
|
||||
|
|
|
@ -44,6 +44,7 @@ import android.widget.Toast;
|
|||
|
||||
import org.shadowice.flocke.andotp.Database.Entry;
|
||||
import org.shadowice.flocke.andotp.Utilities.DatabaseHelper;
|
||||
import org.shadowice.flocke.andotp.Utilities.Settings;
|
||||
import org.shadowice.flocke.andotp.Utilities.TagDialogHelper;
|
||||
import org.shadowice.flocke.andotp.View.ItemTouchHelper.ItemTouchHelperAdapter;
|
||||
import org.shadowice.flocke.andotp.R;
|
||||
|
@ -70,11 +71,13 @@ public class EntriesCardAdapter extends RecyclerView.Adapter<EntryViewHolder>
|
|||
|
||||
private SortMode sortMode = SortMode.UNSORTED;
|
||||
private TagsAdapter tagsFilterAdapter;
|
||||
private Settings settings;
|
||||
|
||||
public EntriesCardAdapter(Context context, TagsAdapter tagsFilterAdapter) {
|
||||
this.context = context;
|
||||
this.sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
this.tagsFilterAdapter = tagsFilterAdapter;
|
||||
this.settings = new Settings(context);
|
||||
loadEntries();
|
||||
}
|
||||
|
||||
|
@ -117,7 +120,7 @@ public class EntriesCardAdapter extends RecyclerView.Adapter<EntryViewHolder>
|
|||
|
||||
for(Entry e : entries) {
|
||||
//Entries with no tags will always be shown
|
||||
Boolean foundMatchingTag = e.getTags().isEmpty();
|
||||
Boolean foundMatchingTag = e.getTags().isEmpty() && settings.getNoTagsToggle();
|
||||
|
||||
for(String tag : tags) {
|
||||
if(e.getTags().contains(tag)) {
|
||||
|
|
|
@ -20,6 +20,29 @@
|
|||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
|
||||
android:text="@string/button_all_tags"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_gravity="center_horizontal">
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="@color/divider" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<CheckedTextView
|
||||
android:id="@+id/no_tags_entries"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?android:attr/listPreferredItemHeightSmall"
|
||||
android:textAppearance="?android:attr/textAppearanceListItemSmall"
|
||||
android:gravity="center_vertical"
|
||||
android:checkMark="?android:attr/listChoiceIndicatorMultiple"
|
||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
|
||||
android:text="@string/button_no_tags"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -35,7 +58,7 @@
|
|||
<ListView
|
||||
android:id="@+id/tags_list_in_drawer"
|
||||
android:layout_width="match_parent"
|
||||
android:dividerHeight="0dp"
|
||||
android:dividerHeight="1dp"
|
||||
android:headerDividersEnabled="false"
|
||||
android:footerDividersEnabled="true"
|
||||
android:layout_height="match_parent" />
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
<string name="settings_key_sort_mode" translatable="false">pref_sort_mode</string>
|
||||
<string name="settings_key_special_features" translatable="false">pref_special_features</string>
|
||||
<string name="settings_key_all_tags_toggle" translatable="false">pref_all_tags_toggle</string>
|
||||
<string name="settings_key_no_tags_toggle" translatable="false">pref_no_tags_toggle</string>
|
||||
<string name="settings_key_tags_toggles" translatable="false">pref_tags_toggles</string>
|
||||
|
||||
<!-- Default values -->
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
<string name="button_new_tag">New tag</string>
|
||||
<string name="button_warned">You have been warned!</string>
|
||||
<string name="button_all_tags">All tags</string>
|
||||
<string name="button_no_tags">No tags</string>
|
||||
|
||||
<!-- Custom formatting -->
|
||||
<string name="format_custom_period">%d s</string>
|
||||
|
|
Loading…
Reference in a new issue