mirror of
https://github.com/gsantner/dandelion
synced 2024-11-24 13:22:08 +01:00
Fixed Layout issues with ThemedEditTextPreferences EditTexts
This commit is contained in:
parent
e3c2e91b70
commit
e66e3cc83d
4 changed files with 31 additions and 4 deletions
|
@ -8,13 +8,16 @@ import android.text.InputType;
|
|||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.EditText;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.github.dfa.diaspora_android.R;
|
||||
import com.github.dfa.diaspora_android.data.AppSettings;
|
||||
import com.github.dfa.diaspora_android.util.AppLog;
|
||||
import com.github.dfa.diaspora_android.util.Helpers;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
@ -93,6 +96,14 @@ public class ThemedIntEditTextPreference extends LinearLayout implements ThemedP
|
|||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
final EditText dialogLayout = (EditText) LayoutInflater.from(context).inflate(R.layout.settings_activity__dialog_proxy, null, false);
|
||||
dialogLayout.setInputType(InputType.TYPE_CLASS_NUMBER);
|
||||
dialogLayout.setSingleLine();
|
||||
FrameLayout container = new FrameLayout(context);
|
||||
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
int marginHoriz = Helpers.dpToPx(context, (int) context.getResources().getDimension(R.dimen.activity_horizontal_margin_half));
|
||||
params.leftMargin = marginHoriz;
|
||||
params.rightMargin = marginHoriz;
|
||||
dialogLayout.setLayoutParams(params);
|
||||
container.addView(dialogLayout);
|
||||
dialogLayout.setText(Integer.toString(appSettings.getThemedIntEditTextPreferenceValue(this)));
|
||||
builder.setTitle(title)
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
|
@ -104,7 +115,7 @@ public class ThemedIntEditTextPreference extends LinearLayout implements ThemedP
|
|||
}
|
||||
}
|
||||
}).setNegativeButton(android.R.string.cancel, null)
|
||||
.setView(dialogLayout)
|
||||
.setView(container)
|
||||
.show();
|
||||
}
|
||||
|
||||
|
|
|
@ -8,13 +8,16 @@ import android.text.InputType;
|
|||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.EditText;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.github.dfa.diaspora_android.R;
|
||||
import com.github.dfa.diaspora_android.data.AppSettings;
|
||||
import com.github.dfa.diaspora_android.util.AppLog;
|
||||
import com.github.dfa.diaspora_android.util.Helpers;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
@ -92,6 +95,14 @@ public class ThemedStringEditTextPreference extends LinearLayout implements Them
|
|||
final EditText dialogLayout = (EditText) LayoutInflater.from(context).inflate(R.layout.settings_activity__dialog_proxy, null, false);
|
||||
dialogLayout.setInputType(InputType.TYPE_CLASS_TEXT);
|
||||
dialogLayout.setText(appSettings.getThemedStringEditTextPreferenceValue(this));
|
||||
dialogLayout.setSingleLine();
|
||||
FrameLayout container = new FrameLayout(context);
|
||||
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
int marginHoriz = Helpers.dpToPx(context, (int) context.getResources().getDimension(R.dimen.activity_horizontal_margin_half));
|
||||
params.leftMargin = marginHoriz;
|
||||
params.rightMargin = marginHoriz;
|
||||
dialogLayout.setLayoutParams(params);
|
||||
container.addView(dialogLayout);
|
||||
builder.setTitle(title)
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
|
@ -102,7 +113,7 @@ public class ThemedStringEditTextPreference extends LinearLayout implements Them
|
|||
}
|
||||
}
|
||||
}).setNegativeButton(android.R.string.cancel, null)
|
||||
.setView(dialogLayout)
|
||||
.setView(container)
|
||||
.show();
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import android.os.Build;
|
|||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.View;
|
||||
|
||||
import com.github.dfa.diaspora_android.R;
|
||||
|
@ -149,4 +150,9 @@ public class Helpers {
|
|||
}
|
||||
return !isOnline;
|
||||
}
|
||||
|
||||
public static int dpToPx(Context context, int dp) {
|
||||
DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
|
||||
return Math.round(dp * (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<EditText xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="@dimen/activity_horizontal_margin"/>
|
||||
android:layout_height="match_parent"/>
|
Loading…
Reference in a new issue