mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 01:08:50 -06:00
Fix small issues with the number picker
This commit is contained in:
@@ -166,7 +166,7 @@ public class ListHabitsController
|
||||
@Override
|
||||
public void onEdit(@NonNull Habit habit, long timestamp)
|
||||
{
|
||||
int oldValue = habit.getCheckmarks().getTodayValue();
|
||||
int oldValue = habit.getCheckmarks().getValues(timestamp, timestamp)[0];
|
||||
screen.showNumberPicker(oldValue, newValue -> {
|
||||
commandRunner.execute(
|
||||
new CreateRepetitionCommand(habit, timestamp, newValue),
|
||||
|
||||
@@ -42,8 +42,10 @@ import java.io.*;
|
||||
|
||||
import javax.inject.*;
|
||||
|
||||
import static android.content.DialogInterface.*;
|
||||
import static android.os.Build.VERSION.*;
|
||||
import static android.os.Build.VERSION_CODES.*;
|
||||
import static android.view.inputmethod.EditorInfo.*;
|
||||
import static org.isoron.uhabits.utils.InterfaceUtils.*;
|
||||
|
||||
@ActivityScope
|
||||
@@ -208,20 +210,29 @@ public class ListHabitsScreen extends BaseScreen
|
||||
picker.setValue(initialValue);
|
||||
picker.setWrapSelectorWheel(false);
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
builder
|
||||
AlertDialog dialog = new AlertDialog.Builder(activity)
|
||||
.setView(view)
|
||||
.setTitle(R.string.change_value)
|
||||
.setPositiveButton(android.R.string.ok, (dialog, which) ->
|
||||
{
|
||||
.setPositiveButton(android.R.string.ok, (d, which) -> {
|
||||
picker.clearFocus();
|
||||
callback.onNumberPicked(picker.getValue());
|
||||
});
|
||||
}).create();
|
||||
|
||||
InterfaceUtils.setupEditorAction(picker, (v, actionId, event) -> {
|
||||
if (actionId == IME_ACTION_DONE)
|
||||
dialog.getButton(BUTTON_POSITIVE).performClick();
|
||||
return false;
|
||||
});
|
||||
|
||||
AlertDialog dialog = builder.create();
|
||||
dialog.show();
|
||||
int width = (int) dpToPixels(activity, 200);
|
||||
int height = (int) dpToPixels(activity, 275);
|
||||
dialog.getWindow().setLayout(width, height);
|
||||
|
||||
Window window = dialog.getWindow();
|
||||
if (window != null)
|
||||
{
|
||||
int width = (int) dpToPixels(activity, 200);
|
||||
int height = (int) dpToPixels(activity, 275);
|
||||
window.setLayout(width, height);
|
||||
}
|
||||
}
|
||||
|
||||
public void showFAQScreen()
|
||||
|
||||
@@ -22,7 +22,10 @@ package org.isoron.uhabits.utils;
|
||||
import android.content.*;
|
||||
import android.content.res.*;
|
||||
import android.graphics.*;
|
||||
import android.support.annotation.*;
|
||||
import android.util.*;
|
||||
import android.view.*;
|
||||
import android.widget.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -39,8 +42,9 @@ public abstract class InterfaceUtils
|
||||
|
||||
public static Typeface getFontAwesome(Context context)
|
||||
{
|
||||
if(fontAwesome == null)
|
||||
fontAwesome = Typeface.createFromAsset(context.getAssets(), "fontawesome-webfont.ttf");
|
||||
if(fontAwesome == null) fontAwesome =
|
||||
Typeface.createFromAsset(context.getAssets(),
|
||||
"fontawesome-webfont.ttf");
|
||||
|
||||
return fontAwesome;
|
||||
}
|
||||
@@ -69,4 +73,18 @@ public abstract class InterfaceUtils
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void setupEditorAction(@NonNull ViewGroup parent,
|
||||
@NonNull TextView.OnEditorActionListener listener)
|
||||
{
|
||||
for (int i = 0; i < parent.getChildCount(); i++)
|
||||
{
|
||||
View child = parent.getChildAt(i);
|
||||
|
||||
if (child instanceof ViewGroup)
|
||||
setupEditorAction((ViewGroup) child, listener);
|
||||
|
||||
if (child instanceof TextView)
|
||||
((TextView) child).setOnEditorActionListener(listener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user