Some layout fixes for the tagging implementation

This commit is contained in:
Jakob Nixdorf 2017-11-17 09:46:07 +01:00
parent d766f15cd1
commit a3f73694d7
No known key found for this signature in database
GPG key ID: BE99BF86574A7DBC
5 changed files with 31 additions and 24 deletions

View file

@ -4,9 +4,11 @@ import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.CheckedTextView;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ListView;
import org.shadowice.flocke.andotp.R;
@ -17,11 +19,20 @@ import java.util.concurrent.Callable;
public class TagDialogHelper {
public static void createTagsDialog(Context context, final TagsAdapter tagsAdapter, final Callable newTagCallable, final Callable selectedTagsCallable) {
int margin = context.getResources().getDimensionPixelSize(R.dimen.activity_margin);
int marginSmall = context.getResources().getDimensionPixelSize(R.dimen.activity_margin_small);
int marginMedium = context.getResources().getDimensionPixelSize(R.dimen.activity_margin_medium);
final EditText input = new EditText(context);
input.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
final FrameLayout inputLayout = new FrameLayout(context);
inputLayout.setPaddingRelative(marginMedium, marginSmall, marginMedium, 0);
inputLayout.addView(input);
final AlertDialog.Builder newTagBuilder = new AlertDialog.Builder(context);
newTagBuilder.setTitle(R.string.button_new_tag)
.setView(input)
.setView(inputLayout)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
@ -44,6 +55,8 @@ public class TagDialogHelper {
});
final ListView tagsSelectionView = new ListView(context);
tagsSelectionView.setDivider(null);
tagsSelectionView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
tagsSelectionView.setAdapter(tagsAdapter);
tagsSelectionView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
@ -55,9 +68,13 @@ public class TagDialogHelper {
}
});
final FrameLayout tagsSelectionLayout = new FrameLayout(context);
tagsSelectionLayout.setPaddingRelative(margin, marginSmall, margin, 0);
tagsSelectionLayout.addView(tagsSelectionView);
final AlertDialog.Builder tagsSelectorBuilder = new AlertDialog.Builder(context);
tagsSelectorBuilder.setTitle(R.string.label_tags)
.setView(tagsSelectionView)
.setView(tagsSelectionLayout)
.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {

View file

@ -222,15 +222,16 @@ public class EntriesCardAdapter extends RecyclerView.Adapter<EntryViewHolder>
public void editEntryLabel(final int pos) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
int marginSmall = context.getResources().getDimensionPixelSize(R.dimen.activity_margin_small);
int marginMedium = context.getResources().getDimensionPixelSize(R.dimen.activity_margin_medium);
final EditText input = new EditText(context);
input.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
input.setText(displayedEntries.get(pos).getLabel());
input.setSingleLine();
FrameLayout container = new FrameLayout(context);
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
params.leftMargin = context.getResources().getDimensionPixelSize(R.dimen.activity_horizontal_margin);
params.rightMargin = context.getResources().getDimensionPixelSize(R.dimen.activity_horizontal_margin);
input.setLayoutParams(params);
container.setPaddingRelative(marginMedium, marginSmall, marginMedium, 0);
container.addView(input);
builder.setTitle(R.string.dialog_title_rename)

View file

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/fab_main_layout"
android:background="?attr/windowBackground"
android:layout_width="@dimen/drawer_width"
@ -20,18 +19,6 @@
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"
@ -50,7 +37,7 @@
<View
android:layout_width="match_parent"
android:layout_height="@dimen/strong_divider_size"
android:layout_height="@dimen/divider_size"
android:background="@color/divider" />
</LinearLayout>
@ -58,7 +45,7 @@
<ListView
android:id="@+id/tags_list_in_drawer"
android:layout_width="match_parent"
android:dividerHeight="1dp"
android:divider="@null"
android:headerDividersEnabled="false"
android:footerDividersEnabled="true"
android:layout_height="match_parent" />

View file

@ -136,10 +136,11 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal" >
<TextView
android:layout_weight="2"
android:layout_weight="3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/label_tags"/>
@ -147,9 +148,9 @@
<Button
android:id="@+id/manual_tags"
style="?android:attr/spinnerStyle"
android:layout_weight="7"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="7"
android:textAlignment="textEnd" />
</LinearLayout>

View file

@ -11,7 +11,8 @@
<dimen name="card_corner_radius">0dp</dimen>
<dimen name="drawer_width">200dp</dimen>
<dimen name="strong_divider_size">2dp</dimen>
<dimen name="divider_size">1dp</dimen>
<!-- FAB Menu -->
<dimen name="fab_small_elevation">2dp</dimen>
<dimen name="fab_small_margin">8dp</dimen>