1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-28 12:56:49 +01:00

Add margins to AlertDialog.Builder

This commit is contained in:
vanous 2020-08-24 13:50:10 +02:00
parent 9b30369a88
commit 34eee787d7
4 changed files with 20 additions and 20 deletions

View File

@ -30,10 +30,12 @@ import android.util.TypedValue;
import android.view.Gravity;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TableLayout;
@ -169,9 +171,15 @@ public class ActivitySummaryDetail extends AbstractGBActivity {
input.setInputType(InputType.TYPE_CLASS_TEXT);
String name = currentItem.getName();
input.setText((name != null) ? name : "");
FrameLayout container = new FrameLayout(ActivitySummaryDetail.this);
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
params.leftMargin = getResources().getDimensionPixelSize(R.dimen.dialog_margin);
params.rightMargin = getResources().getDimensionPixelSize(R.dimen.dialog_margin);
input.setLayoutParams(params);
container.addView(input);
new AlertDialog.Builder(ActivitySummaryDetail.this) // TODO: very raw at this point, make better drawable layout, already started here: R.style.GadgetbridgeTheme_DialogTheme)
.setView(input)
new AlertDialog.Builder(ActivitySummaryDetail.this)
.setView(container)
.setCancelable(true)
.setTitle(ActivitySummaryDetail.this.getString(R.string.activity_summary_edit_name_title))
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

View File

@ -30,6 +30,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
@ -56,6 +57,7 @@ import java.util.Locale;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.activities.ActivitySummariesActivity;
import nodomain.freeyourgadget.gadgetbridge.activities.ActivitySummaryDetail;
import nodomain.freeyourgadget.gadgetbridge.activities.ConfigureAlarms;
import nodomain.freeyourgadget.gadgetbridge.activities.VibrationActivity;
import nodomain.freeyourgadget.gadgetbridge.activities.charts.ChartsActivity;
@ -484,10 +486,16 @@ public class GBDeviceAdapterv2 extends RecyclerView.Adapter<GBDeviceAdapterv2.Vi
final EditText input = new EditText(context);
input.setInputType(InputType.TYPE_CLASS_TEXT);
input.setText(device.getAlias());
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.dialog_margin);
params.rightMargin = context.getResources().getDimensionPixelSize(R.dimen.dialog_margin);
input.setLayoutParams(params);
container.addView(input);
// Specify the type of input expected; this, for example, sets the input as a password, and will mask the text
new AlertDialog.Builder(context)
.setView(input)
.setView(container)
.setCancelable(true)
.setTitle(context.getString(R.string.controlcenter_set_alias))
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

View File

@ -13,4 +13,5 @@ http://developer.android.com/guide/topics/appwidgets/index.html#CreatingLayout
<dimen name="nav_header_vertical_spacing">16dp</dimen>
<dimen name="nav_header_height">160dp</dimen>
<dimen name="fab_margin">16dp</dimen>
<dimen name="dialog_margin">20dp</dimen>
</resources>

View File

@ -65,21 +65,4 @@
<item tools:targetApi="21" name="android:navigationBarColor">@color/primarydark_dark</item>
<item name="android:windowBackground">@drawable/splash</item>
</style>
<!-- initial start of work on a Dialog Alert popup, TODO: continue -->
<style name="GadgetbridgeTheme.DialogTheme">
<!-- Fill the screen -->
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<!-- No backgrounds, titles or window float
<item name="android:windowBackground">@null</item>
-->
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<!-- Just to prove it's working
<item name="android:background">#ff0000</item>
-->
</style>
</resources>