forked from mirrors/Fedilab
parent
74599d8a7f
commit
536af42e27
3 changed files with 28 additions and 12 deletions
|
@ -109,7 +109,8 @@ public class FilterActivity extends BaseActivity implements FilterAdapter.Delete
|
||||||
|
|
||||||
popupAddFilterBinding.addKeyword.setOnClickListener(v -> {
|
popupAddFilterBinding.addKeyword.setOnClickListener(v -> {
|
||||||
KeywordsLayoutBinding keywordsLayoutBinding = KeywordsLayoutBinding.inflate(LayoutInflater.from(context));
|
KeywordsLayoutBinding keywordsLayoutBinding = KeywordsLayoutBinding.inflate(LayoutInflater.from(context));
|
||||||
keywordsLayoutBinding.deleteKeyword.setOnClickListener(v2 -> popupAddFilterBinding.keywordsContainer.removeView(keywordsLayoutBinding.deleteKeyword));
|
keywordsLayoutBinding.deleteKeyword.setOnClickListener(v2 -> popupAddFilterBinding.keywordsContainer.removeView(keywordsLayoutBinding.getRoot()));
|
||||||
|
keywordsLayoutBinding.deleteKeyword.setBackgroundTintList(ThemeHelper.getButtonActionColorStateList(context));
|
||||||
popupAddFilterBinding.keywordsContainer.addView(keywordsLayoutBinding.getRoot());
|
popupAddFilterBinding.keywordsContainer.addView(keywordsLayoutBinding.getRoot());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -140,14 +141,22 @@ public class FilterActivity extends BaseActivity implements FilterAdapter.Delete
|
||||||
KeywordsLayoutBinding keywordsLayoutBinding = KeywordsLayoutBinding.inflate(LayoutInflater.from(context));
|
KeywordsLayoutBinding keywordsLayoutBinding = KeywordsLayoutBinding.inflate(LayoutInflater.from(context));
|
||||||
keywordsLayoutBinding.keywordPhrase.setText(filterKeyword.keyword);
|
keywordsLayoutBinding.keywordPhrase.setText(filterKeyword.keyword);
|
||||||
keywordsLayoutBinding.wholeWord.setChecked(filterKeyword.whole_word);
|
keywordsLayoutBinding.wholeWord.setChecked(filterKeyword.whole_word);
|
||||||
keywordsLayoutBinding.deleteKeyword.setOnClickListener(v -> popupAddFilterBinding.keywordsContainer.removeView(keywordsLayoutBinding.deleteKeyword));
|
keywordsLayoutBinding.deleteKeyword.setOnClickListener(v -> popupAddFilterBinding.keywordsContainer.removeView(keywordsLayoutBinding.getRoot()));
|
||||||
|
keywordsLayoutBinding.deleteKeyword.setBackgroundTintList(ThemeHelper.getButtonActionColorStateList(context));
|
||||||
popupAddFilterBinding.keywordsContainer.addView(keywordsLayoutBinding.getRoot());
|
popupAddFilterBinding.keywordsContainer.addView(keywordsLayoutBinding.getRoot());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (popupAddFilterBinding.keywordsContainer.getChildCount() == 0) {
|
||||||
|
KeywordsLayoutBinding keywordsLayoutBinding = KeywordsLayoutBinding.inflate(LayoutInflater.from(context));
|
||||||
|
keywordsLayoutBinding.deleteKeyword.setOnClickListener(v -> popupAddFilterBinding.keywordsContainer.removeView(keywordsLayoutBinding.getRoot()));
|
||||||
|
keywordsLayoutBinding.deleteKeyword.setBackgroundTintList(ThemeHelper.getButtonActionColorStateList(context));
|
||||||
|
popupAddFilterBinding.keywordsContainer.addView(keywordsLayoutBinding.getRoot());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
//Add at least a view
|
//Add at least a view
|
||||||
KeywordsLayoutBinding keywordsLayoutBinding = KeywordsLayoutBinding.inflate(LayoutInflater.from(context));
|
KeywordsLayoutBinding keywordsLayoutBinding = KeywordsLayoutBinding.inflate(LayoutInflater.from(context));
|
||||||
keywordsLayoutBinding.deleteKeyword.setOnClickListener(v -> popupAddFilterBinding.keywordsContainer.removeView(keywordsLayoutBinding.deleteKeyword));
|
keywordsLayoutBinding.deleteKeyword.setOnClickListener(v -> popupAddFilterBinding.keywordsContainer.removeView(keywordsLayoutBinding.getRoot()));
|
||||||
|
keywordsLayoutBinding.deleteKeyword.setBackgroundTintList(ThemeHelper.getButtonActionColorStateList(context));
|
||||||
popupAddFilterBinding.keywordsContainer.addView(keywordsLayoutBinding.getRoot());
|
popupAddFilterBinding.keywordsContainer.addView(keywordsLayoutBinding.getRoot());
|
||||||
}
|
}
|
||||||
popupAddFilterBinding.actionRemove.setOnClickListener(v -> {
|
popupAddFilterBinding.actionRemove.setOnClickListener(v -> {
|
||||||
|
@ -186,7 +195,10 @@ public class FilterActivity extends BaseActivity implements FilterAdapter.Delete
|
||||||
keywordsAttributes.add(keywordsAttr);
|
keywordsAttributes.add(keywordsAttr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (popupAddFilterBinding.addTitle.getText().toString().trim().isEmpty()) {
|
||||||
|
popupAddFilterBinding.addTitle.setError(context.getString(R.string.cannot_be_empty));
|
||||||
|
canBeSent = false;
|
||||||
|
}
|
||||||
if (!popupAddFilterBinding.contextConversation.isChecked() && !popupAddFilterBinding.contextHome.isChecked() && !popupAddFilterBinding.contextPublic.isChecked() && !popupAddFilterBinding.contextNotification.isChecked() && !popupAddFilterBinding.contextProfiles.isChecked()) {
|
if (!popupAddFilterBinding.contextConversation.isChecked() && !popupAddFilterBinding.contextHome.isChecked() && !popupAddFilterBinding.contextPublic.isChecked() && !popupAddFilterBinding.contextNotification.isChecked() && !popupAddFilterBinding.contextProfiles.isChecked()) {
|
||||||
popupAddFilterBinding.contextDescription.setError(context.getString(R.string.cannot_be_empty));
|
popupAddFilterBinding.contextDescription.setError(context.getString(R.string.cannot_be_empty));
|
||||||
canBeSent = false;
|
canBeSent = false;
|
||||||
|
@ -212,6 +224,7 @@ public class FilterActivity extends BaseActivity implements FilterAdapter.Delete
|
||||||
} else {
|
} else {
|
||||||
filterSent.expires_at = null;
|
filterSent.expires_at = null;
|
||||||
}
|
}
|
||||||
|
filterSent.title = popupAddFilterBinding.addTitle.getText().toString().trim();
|
||||||
filterSent.filter_action = popupAddFilterBinding.actionHide.isChecked() ? "hide" : "warn";
|
filterSent.filter_action = popupAddFilterBinding.actionHide.isChecked() ? "hide" : "warn";
|
||||||
if (filter != null) {
|
if (filter != null) {
|
||||||
filtersVM.editFilter(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, filter.id, filterSent.title, filterSent.expires_at, filterSent.context, filterSent.filter_action, keywordsAttributes)
|
filtersVM.editFilter(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, filter.id, filterSent.title, filterSent.expires_at, filterSent.context, filterSent.filter_action, keywordsAttributes)
|
||||||
|
|
|
@ -46,6 +46,8 @@
|
||||||
android:layout_margin="5dp"
|
android:layout_margin="5dp"
|
||||||
android:contentDescription="@string/action_update_filter"
|
android:contentDescription="@string/action_update_filter"
|
||||||
android:padding="6dp"
|
android:padding="6dp"
|
||||||
|
app:iconTint="@color/cyanea_accent_dark_reference"
|
||||||
|
app:strokeColor="@color/cyanea_accent_dark_reference"
|
||||||
app:icon="@drawable/ic_baseline_edit_24" />
|
app:icon="@drawable/ic_baseline_edit_24" />
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
|
@ -56,5 +58,7 @@
|
||||||
android:layout_margin="5dp"
|
android:layout_margin="5dp"
|
||||||
android:contentDescription="@string/action_filter_delete"
|
android:contentDescription="@string/action_filter_delete"
|
||||||
android:padding="6dp"
|
android:padding="6dp"
|
||||||
|
app:iconTint="@color/cyanea_accent_dark_reference"
|
||||||
|
app:strokeColor="@color/cyanea_accent_dark_reference"
|
||||||
app:icon="@drawable/ic_baseline_delete_24" />
|
app:icon="@drawable/ic_baseline_delete_24" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -133,6 +133,7 @@
|
||||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/filter_action"
|
android:text="@string/filter_action"
|
||||||
|
@ -152,7 +153,6 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="5dp"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<androidx.appcompat.widget.LinearLayoutCompat
|
<androidx.appcompat.widget.LinearLayoutCompat
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -162,15 +162,14 @@
|
||||||
android:id="@+id/action_hide"
|
android:id="@+id/action_hide"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/hide_with_warning"
|
android:text="@string/hide_with_warning" />
|
||||||
android:textSize="16sp"
|
|
||||||
android:textStyle="bold" />
|
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatTextView
|
<androidx.appcompat.widget.AppCompatTextView
|
||||||
android:id="@+id/val1_more"
|
android:id="@+id/val1_more"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="30dp"
|
android:layout_marginStart="30dp"
|
||||||
|
android:textSize="12sp"
|
||||||
android:text="@string/hide_with_warning_description" />
|
android:text="@string/hide_with_warning_description" />
|
||||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||||
|
|
||||||
|
@ -184,20 +183,20 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/hide_completely"
|
android:text="@string/hide_completely"
|
||||||
android:textSize="16sp"
|
android:checked="true" />
|
||||||
android:checked="true"
|
|
||||||
android:textStyle="bold" />
|
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatTextView
|
<androidx.appcompat.widget.AppCompatTextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="30dp"
|
android:layout_marginStart="30dp"
|
||||||
|
android:textSize="12sp"
|
||||||
android:text="@string/hide_completely_description" />
|
android:text="@string/hide_completely_description" />
|
||||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||||
|
|
||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
|
|
||||||
<androidx.appcompat.widget.LinearLayoutCompat
|
<androidx.appcompat.widget.LinearLayoutCompat
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
@ -235,7 +234,7 @@
|
||||||
android:text="@string/add_keyword"
|
android:text="@string/add_keyword"
|
||||||
android:textColor="@color/cyanea_accent_dark_reference"
|
android:textColor="@color/cyanea_accent_dark_reference"
|
||||||
app:icon="@drawable/ic_baseline_add_24"
|
app:icon="@drawable/ic_baseline_add_24"
|
||||||
app:iconTint="@color/cyanea_primary_dark_reference"
|
app:iconTint="@color/cyanea_accent_dark_reference"
|
||||||
app:strokeColor="@color/cyanea_accent_dark_reference" />
|
app:strokeColor="@color/cyanea_accent_dark_reference" />
|
||||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue