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
|
@Override
|
||||||
public void onEdit(@NonNull Habit habit, long timestamp)
|
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 -> {
|
screen.showNumberPicker(oldValue, newValue -> {
|
||||||
commandRunner.execute(
|
commandRunner.execute(
|
||||||
new CreateRepetitionCommand(habit, timestamp, newValue),
|
new CreateRepetitionCommand(habit, timestamp, newValue),
|
||||||
|
|||||||
@@ -42,8 +42,10 @@ import java.io.*;
|
|||||||
|
|
||||||
import javax.inject.*;
|
import javax.inject.*;
|
||||||
|
|
||||||
|
import static android.content.DialogInterface.*;
|
||||||
import static android.os.Build.VERSION.*;
|
import static android.os.Build.VERSION.*;
|
||||||
import static android.os.Build.VERSION_CODES.*;
|
import static android.os.Build.VERSION_CODES.*;
|
||||||
|
import static android.view.inputmethod.EditorInfo.*;
|
||||||
import static org.isoron.uhabits.utils.InterfaceUtils.*;
|
import static org.isoron.uhabits.utils.InterfaceUtils.*;
|
||||||
|
|
||||||
@ActivityScope
|
@ActivityScope
|
||||||
@@ -208,20 +210,29 @@ public class ListHabitsScreen extends BaseScreen
|
|||||||
picker.setValue(initialValue);
|
picker.setValue(initialValue);
|
||||||
picker.setWrapSelectorWheel(false);
|
picker.setWrapSelectorWheel(false);
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
AlertDialog dialog = new AlertDialog.Builder(activity)
|
||||||
builder
|
|
||||||
.setView(view)
|
.setView(view)
|
||||||
.setTitle(R.string.change_value)
|
.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());
|
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();
|
dialog.show();
|
||||||
int width = (int) dpToPixels(activity, 200);
|
|
||||||
int height = (int) dpToPixels(activity, 275);
|
Window window = dialog.getWindow();
|
||||||
dialog.getWindow().setLayout(width, height);
|
if (window != null)
|
||||||
|
{
|
||||||
|
int width = (int) dpToPixels(activity, 200);
|
||||||
|
int height = (int) dpToPixels(activity, 275);
|
||||||
|
window.setLayout(width, height);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showFAQScreen()
|
public void showFAQScreen()
|
||||||
|
|||||||
@@ -22,7 +22,10 @@ package org.isoron.uhabits.utils;
|
|||||||
import android.content.*;
|
import android.content.*;
|
||||||
import android.content.res.*;
|
import android.content.res.*;
|
||||||
import android.graphics.*;
|
import android.graphics.*;
|
||||||
|
import android.support.annotation.*;
|
||||||
import android.util.*;
|
import android.util.*;
|
||||||
|
import android.view.*;
|
||||||
|
import android.widget.*;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@@ -39,8 +42,9 @@ public abstract class InterfaceUtils
|
|||||||
|
|
||||||
public static Typeface getFontAwesome(Context context)
|
public static Typeface getFontAwesome(Context context)
|
||||||
{
|
{
|
||||||
if(fontAwesome == null)
|
if(fontAwesome == null) fontAwesome =
|
||||||
fontAwesome = Typeface.createFromAsset(context.getAssets(), "fontawesome-webfont.ttf");
|
Typeface.createFromAsset(context.getAssets(),
|
||||||
|
"fontawesome-webfont.ttf");
|
||||||
|
|
||||||
return fontAwesome;
|
return fontAwesome;
|
||||||
}
|
}
|
||||||
@@ -69,4 +73,18 @@ public abstract class InterfaceUtils
|
|||||||
return false;
|
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