Related
Does anyone have any information about how to adjust screen sensitivity under Android, specifricaly Froyo on Nexus One?
I'm trying to research this topic but there seems to be very little information about this. I can't find any tool, script or custom rom that would allow screen sensitivity to be adjusted.
I found a thread talking about doing it for Liqid's touch using script but that's about it. I took a look on the script and I can't move forward with it as the path's script uses do not exists in my Nexus One. If anyone has any experience with this please share. The goal is to make the screen more sensitive then it is as a default.
Thanks.
Thread reference above:
android.modaco.com/content-page/309503/increase-touch-screen-sensitivity-only-tested-on-liquide-1-100-05-based-roms/page/40/
Script:
#!/system/bin/sh
sensitivity=25
noise=25
echo "set sensitivity to $sensitivity"
echo $sensitivity > /sys/devices/platform/i2c-adapter/i2c-0/0-005c/sensitivity
echo "set noise to $noise"
echo $noise > /sys/devices/platform/i2c-adapter/i2c-0/0-005c/noise
echo "done"
Sorry for bringing back something from the dead, but I've been researching about this. Nexus One screen sensitivity is low, compared to other touch screens I've experimented with. I know Nexus One is using a Synaptics board. Digging in the source code of Android, I found that the settings on the device itself are located here:
/system/usr/idc/synaptics-rmi-touchscreen.idc
The contents of the file as per 2.3.7 are these (they are the same since Gingerbread):
# Copyright (C) 2010 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Input Device Calibration File for the Passion touch screen.
#
# These calibration values are derived from empirical measurements
# and may not be appropriate for use with other touch screens.
# Refer to the input device calibration documentation for more details.
#
# Touch Size
touch.touchSize.calibration = pressure
# Tool Size
# Driver reports tool size as a linear width measurement summed over
# all contact points.
#
# Raw width field measures approx. 1 unit per millimeter
# of tool size on the surface where a raw width of 1 corresponds
# to about 17mm of physical size. Given that the display resolution
# is 10px per mm we obtain a scale factor of 10 pixels / unit and
# a bias of 160 pixels. In addition, the raw width represents a
# sum of all contact area so we note this fact in the calibration.
touch.toolSize.calibration = linear
touch.toolSize.linearScale = 10
touch.toolSize.linearBias = 160
touch.toolSize.isSummed = 1
# Pressure
# Driver reports signal strength as pressure.
#
# A normal thumb touch while touching the back of the device
# typically registers about 100 signal strength units although
# this value is highly variable and is sensitive to contact area,
# manner of contact and environmental conditions. We set the
# scale so that a normal touch with good signal strength will be
# reported as having a pressure somewhere in the vicinity of 1.0,
# a featherlight touch will be below 1.0 and a heavy or large touch
# will be above 1.0. We don't expect these values to be accurate.
touch.pressure.calibration = amplitude
touch.pressure.source = default
touch.pressure.scale = 0.01
# Size
touch.size.calibration = normalized
# Orientation
touch.orientation.calibration = none
Click to expand...
Click to collapse
Also, in the kernel, the synaptics driver can be configured to be more sensitive. It is located here on the kernel source:
drivers/input/touchscreen/synaptics_i2c_rmi.c
/*
*
* Copyright (C) 2007 Google, Inc.
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#include <linux/module.h>
#include <linux/delay.h>
#include <linux/earlysuspend.h>
#include <linux/hrtimer.h>
#include <linux/i2c.h>
#include <linux/input.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/synaptics_i2c_rmi.h>
static struct workqueue_struct *synaptics_wq;
struct synaptics_ts_data {
uint16_t addr;
struct i2c_client *client;
struct input_dev *input_dev;
int use_irq;
bool has_relative_report;
struct hrtimer timer;
struct work_struct work;
uint16_t max[2];
int snap_state[2][2];
int snap_down_on[2];
int snap_down_off[2];
int snap_up_on[2];
int snap_up_off[2];
int snap_down[2];
int snap_up[2];
uint32_t flags;
int reported_finger_count;
int8_t sensitivity_adjust;
int (*power)(int on);
struct early_suspend early_suspend;
};
#ifdef CONFIG_HAS_EARLYSUSPEND
static void synaptics_ts_early_suspend(struct early_suspend *h);
static void synaptics_ts_late_resume(struct early_suspend *h);
#endif
static int synaptics_init_panel(struct synaptics_ts_data *ts)
{
int ret;
ret = i2c_smbus_write_byte_data(ts->client, 0xff, 0x10); /* page select = 0x10 */
if (ret < 0) {
printk(KERN_ERR "i2c_smbus_write_byte_data failed for page select\n");
goto err_page_select_failed;
}
ret = i2c_smbus_write_byte_data(ts->client, 0x41, 0x04); /* Set "No Clip Z" */
if (ret < 0)
printk(KERN_ERR "i2c_smbus_write_byte_data failed for No Clip Z\n");
ret = i2c_smbus_write_byte_data(ts->client, 0x44,
ts->sensitivity_adjust);
if (ret < 0)
pr_err("synaptics_ts: failed to set Sensitivity Adjust\n");
err_page_select_failed:
ret = i2c_smbus_write_byte_data(ts->client, 0xff, 0x04); /* page select = 0x04 */
if (ret < 0)
printk(KERN_ERR "i2c_smbus_write_byte_data failed for page select\n");
ret = i2c_smbus_write_byte_data(ts->client, 0xf0, 0x81); /* normal operation, 80 reports per second */
if (ret < 0)
printk(KERN_ERR "synaptics_ts_resume: i2c_smbus_write_byte_data failed\n");
return ret;
}
static void synaptics_ts_work_func(struct work_struct *work)
{
int i;
int ret;
int bad_data = 0;
struct i2c_msg msg[2];
uint8_t start_reg;
uint8_t buf[15];
struct synaptics_ts_data *ts = container_of(work, struct synaptics_ts_data, work);
int buf_len = ts->has_relative_report ? 15 : 13;
msg[0].addr = ts->client->addr;
msg[0].flags = 0;
msg[0].len = 1;
msg[0].buf = &start_reg;
start_reg = 0x00;
msg[1].addr = ts->client->addr;
msg[1].flags = I2C_M_RD;
msg[1].len = buf_len;
msg[1].buf = buf;
/* printk("synaptics_ts_work_func\n"); */
for (i = 0; i < ((ts->use_irq && !bad_data) ? 1 : 10); i++) {
ret = i2c_transfer(ts->client->adapter, msg, 2);
if (ret < 0) {
printk(KERN_ERR "synaptics_ts_work_func: i2c_transfer failed\n");
bad_data = 1;
} else {
/* printk("synaptics_ts_work_func: %x %x %x %x %x %x" */
/* " %x %x %x %x %x %x %x %x %x, ret %d\n", */
/* buf[0], buf[1], buf[2], buf[3], */
/* buf[4], buf[5], buf[6], buf[7], */
/* buf[8], buf[9], buf[10], buf[11], */
/* buf[12], buf[13], buf[14], ret); */
if ((buf[buf_len - 1] & 0xc0) != 0x40) {
printk(KERN_WARNING "synaptics_ts_work_func:"
" bad read %x %x %x %x %x %x %x %x %x"
" %x %x %x %x %x %x, ret %d\n",
buf[0], buf[1], buf[2], buf[3],
buf[4], buf[5], buf[6], buf[7],
buf[8], buf[9], buf[10], buf[11],
buf[12], buf[13], buf[14], ret);
if (bad_data)
synaptics_init_panel(ts);
bad_data = 1;
continue;
}
bad_data = 0;
if ((buf[buf_len - 1] & 1) == 0) {
/* printk("read %d coordinates\n", i); */
break;
} else {
int pos[2][2];
int f, a;
int base;
/* int x = buf[3] | (uint16_t)(buf[2] & 0x1f) << 8; */
/* int y = buf[5] | (uint16_t)(buf[4] & 0x1f) << 8; */
int z = buf[1];
int w = buf[0] >> 4;
int finger = buf[0] & 7;
/* int x2 = buf[3+6] | (uint16_t)(buf[2+6] & 0x1f) << 8; */
/* int y2 = buf[5+6] | (uint16_t)(buf[4+6] & 0x1f) << 8; */
/* int z2 = buf[1+6]; */
/* int w2 = buf[0+6] >> 4; */
/* int finger2 = buf[0+6] & 7; */
/* int dx = (int8_t)buf[12]; */
/* int dy = (int8_t)buf[13]; */
int finger2_pressed;
/* printk("x %4d, y %4d, z %3d, w %2d, F %d, 2nd: x %4d, y %4d, z %3d, w %2d, F %d, dx %4d, dy %4d\n", */
/* x, y, z, w, finger, */
/* x2, y2, z2, w2, finger2, */
/* dx, dy); */
base = 2;
for (f = 0; f < 2; f++) {
uint32_t flip_flag = SYNAPTICS_FLIP_X;
for (a = 0; a < 2; a++) {
int p = buf[base + 1];
p |= (uint16_t)(buf[base] & 0x1f) << 8;
if (ts->flags & flip_flag)
p = ts->max[a] - p;
if (ts->flags & SYNAPTICS_SNAP_TO_INACTIVE_EDGE) {
if (ts->snap_state[f][a]) {
if (p <= ts->snap_down_off[a])
p = ts->snap_down[a];
else if (p >= ts->snap_up_off[a])
p = ts->snap_up[a];
else
ts->snap_state[f][a] = 0;
} else {
if (p <= ts->snap_down_on[a]) {
p = ts->snap_down[a];
ts->snap_state[f][a] = 1;
} else if (p >= ts->snap_up_on[a]) {
p = ts->snap_up[a];
ts->snap_state[f][a] = 1;
}
}
}
pos[f][a] = p;
base += 2;
flip_flag <<= 1;
}
base += 2;
if (ts->flags & SYNAPTICS_SWAP_XY)
swap(pos[f][0], pos[f][1]);
}
if (z) {
input_report_abs(ts->input_dev, ABS_X, pos[0][0]);
input_report_abs(ts->input_dev, ABS_Y, pos[0][1]);
}
input_report_abs(ts->input_dev, ABS_PRESSURE, z);
input_report_abs(ts->input_dev, ABS_TOOL_WIDTH, w);
input_report_key(ts->input_dev, BTN_TOUCH, finger);
finger2_pressed = finger > 1 && finger != 7;
input_report_key(ts->input_dev, BTN_2, finger2_pressed);
if (finger2_pressed) {
input_report_abs(ts->input_dev, ABS_HAT0X, pos[1][0]);
input_report_abs(ts->input_dev, ABS_HAT0Y, pos[1][1]);
}
if (!finger)
z = 0;
input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, z);
input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, w);
input_report_abs(ts->input_dev, ABS_MT_POSITION_X, pos[0][0]);
input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, pos[0][1]);
input_mt_sync(ts->input_dev);
if (finger2_pressed) {
input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, z);
input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, w);
input_report_abs(ts->input_dev, ABS_MT_POSITION_X, pos[1][0]);
input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, pos[1][1]);
input_mt_sync(ts->input_dev);
} else if (ts->reported_finger_count > 1) {
input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0);
input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, 0);
input_mt_sync(ts->input_dev);
}
ts->reported_finger_count = finger;
input_sync(ts->input_dev);
}
}
}
if (ts->use_irq)
enable_irq(ts->client->irq);
}
static enum hrtimer_restart synaptics_ts_timer_func(struct hrtimer *timer)
{
struct synaptics_ts_data *ts = container_of(timer, struct synaptics_ts_data, timer);
/* printk("synaptics_ts_timer_func\n"); */
queue_work(synaptics_wq, &ts->work);
hrtimer_start(&ts->timer, ktime_set(0, 12500000), HRTIMER_MODE_REL);
return HRTIMER_NORESTART;
}
static irqreturn_t synaptics_ts_irq_handler(int irq, void *dev_id)
{
struct synaptics_ts_data *ts = dev_id;
/* printk("synaptics_ts_irq_handler\n"); */
disable_irq_nosync(ts->client->irq);
queue_work(synaptics_wq, &ts->work);
return IRQ_HANDLED;
}
static int synaptics_ts_probe(
struct i2c_client *client, const struct i2c_device_id *id)
{
struct synaptics_ts_data *ts;
uint8_t buf0[4];
uint8_t buf1[8];
struct i2c_msg msg[2];
int ret = 0;
uint16_t max_x, max_y;
int fuzz_x, fuzz_y, fuzz_p, fuzz_w;
struct synaptics_i2c_rmi_platform_data *pdata;
unsigned long irqflags;
int inactive_area_left;
int inactive_area_right;
int inactive_area_top;
int inactive_area_bottom;
int snap_left_on;
int snap_left_off;
int snap_right_on;
int snap_right_off;
int snap_top_on;
int snap_top_off;
int snap_bottom_on;
int snap_bottom_off;
uint32_t panel_version;
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
printk(KERN_ERR "synaptics_ts_probe: need I2C_FUNC_I2C\n");
ret = -ENODEV;
goto err_check_functionality_failed;
}
ts = kzalloc(sizeof(*ts), GFP_KERNEL);
if (ts == NULL) {
ret = -ENOMEM;
goto err_alloc_data_failed;
}
INIT_WORK(&ts->work, synaptics_ts_work_func);
ts->client = client;
i2c_set_clientdata(client, ts);
pdata = client->dev.platform_data;
if (pdata)
ts->power = pdata->power;
if (ts->power) {
ret = ts->power(1);
if (ret < 0) {
printk(KERN_ERR "synaptics_ts_probe power on failed\n");
goto err_power_failed;
}
}
ret = i2c_smbus_write_byte_data(ts->client, 0xf4, 0x01); /* device command = reset */
if (ret < 0) {
printk(KERN_ERR "i2c_smbus_write_byte_data failed\n");
/* fail? */
}
{
int retry = 10;
while (retry-- > 0) {
ret = i2c_smbus_read_byte_data(ts->client, 0xe4);
if (ret >= 0)
break;
msleep(100);
}
}
if (ret < 0) {
printk(KERN_ERR "i2c_smbus_read_byte_data failed\n");
goto err_detect_failed;
}
printk(KERN_INFO "synaptics_ts_probe: Product Major Version %x\n", ret);
panel_version = ret << 8;
ret = i2c_smbus_read_byte_data(ts->client, 0xe5);
if (ret < 0) {
printk(KERN_ERR "i2c_smbus_read_byte_data failed\n");
goto err_detect_failed;
}
printk(KERN_INFO "synaptics_ts_probe: Product Minor Version %x\n", ret);
panel_version |= ret;
ret = i2c_smbus_read_byte_data(ts->client, 0xe3);
if (ret < 0) {
printk(KERN_ERR "i2c_smbus_read_byte_data failed\n");
goto err_detect_failed;
}
printk(KERN_INFO "synaptics_ts_probe: product property %x\n", ret);
if (pdata) {
while (pdata->version > panel_version)
pdata++;
ts->flags = pdata->flags;
ts->sensitivity_adjust = pdata->sensitivity_adjust;
irqflags = pdata->irqflags;
inactive_area_left = pdata->inactive_left;
inactive_area_right = pdata->inactive_right;
inactive_area_top = pdata->inactive_top;
inactive_area_bottom = pdata->inactive_bottom;
snap_left_on = pdata->snap_left_on;
snap_left_off = pdata->snap_left_off;
snap_right_on = pdata->snap_right_on;
snap_right_off = pdata->snap_right_off;
snap_top_on = pdata->snap_top_on;
snap_top_off = pdata->snap_top_off;
snap_bottom_on = pdata->snap_bottom_on;
snap_bottom_off = pdata->snap_bottom_off;
fuzz_x = pdata->fuzz_x;
fuzz_y = pdata->fuzz_y;
fuzz_p = pdata->fuzz_p;
fuzz_w = pdata->fuzz_w;
} else {
irqflags = 0;
inactive_area_left = 0;
inactive_area_right = 0;
inactive_area_top = 0;
inactive_area_bottom = 0;
snap_left_on = 0;
snap_left_off = 0;
snap_right_on = 0;
snap_right_off = 0;
snap_top_on = 0;
snap_top_off = 0;
snap_bottom_on = 0;
snap_bottom_off = 0;
fuzz_x = 0;
fuzz_y = 0;
fuzz_p = 0;
fuzz_w = 0;
}
ret = i2c_smbus_read_byte_data(ts->client, 0xf0);
if (ret < 0) {
printk(KERN_ERR "i2c_smbus_read_byte_data failed\n");
goto err_detect_failed;
}
printk(KERN_INFO "synaptics_ts_probe: device control %x\n", ret);
ret = i2c_smbus_read_byte_data(ts->client, 0xf1);
if (ret < 0) {
printk(KERN_ERR "i2c_smbus_read_byte_data failed\n");
goto err_detect_failed;
}
printk(KERN_INFO "synaptics_ts_probe: interrupt enable %x\n", ret);
ret = i2c_smbus_write_byte_data(ts->client, 0xf1, 0); /* disable interrupt */
if (ret < 0) {
printk(KERN_ERR "i2c_smbus_write_byte_data failed\n");
goto err_detect_failed;
}
msg[0].addr = ts->client->addr;
msg[0].flags = 0;
msg[0].len = 1;
msg[0].buf = buf0;
buf0[0] = 0xe0;
msg[1].addr = ts->client->addr;
msg[1].flags = I2C_M_RD;
msg[1].len = 8;
msg[1].buf = buf1;
ret = i2c_transfer(ts->client->adapter, msg, 2);
if (ret < 0) {
printk(KERN_ERR "i2c_transfer failed\n");
goto err_detect_failed;
}
printk(KERN_INFO "synaptics_ts_probe: 0xe0: %x %x %x %x %x %x %x %x\n",
buf1[0], buf1[1], buf1[2], buf1[3],
buf1[4], buf1[5], buf1[6], buf1[7]);
ret = i2c_smbus_write_byte_data(ts->client, 0xff, 0x10); /* page select = 0x10 */
if (ret < 0) {
printk(KERN_ERR "i2c_smbus_write_byte_data failed for page select\n");
goto err_detect_failed;
}
ret = i2c_smbus_read_word_data(ts->client, 0x02);
if (ret < 0) {
printk(KERN_ERR "i2c_smbus_read_word_data failed\n");
goto err_detect_failed;
}
ts->has_relative_report = !(ret & 0x100);
printk(KERN_INFO "synaptics_ts_probe: Sensor properties %x\n", ret);
ret = i2c_smbus_read_word_data(ts->client, 0x04);
if (ret < 0) {
printk(KERN_ERR "i2c_smbus_read_word_data failed\n");
goto err_detect_failed;
}
ts->max[0] = max_x = (ret >> 8 & 0xff) | ((ret & 0x1f) << 8);
ret = i2c_smbus_read_word_data(ts->client, 0x06);
if (ret < 0) {
printk(KERN_ERR "i2c_smbus_read_word_data failed\n");
goto err_detect_failed;
}
ts->max[1] = max_y = (ret >> 8 & 0xff) | ((ret & 0x1f) << 8);
if (ts->flags & SYNAPTICS_SWAP_XY)
swap(max_x, max_y);
ret = synaptics_init_panel(ts); /* will also switch back to page 0x04 */
if (ret < 0) {
printk(KERN_ERR "synaptics_init_panel failed\n");
goto err_detect_failed;
}
ts->input_dev = input_allocate_device();
if (ts->input_dev == NULL) {
ret = -ENOMEM;
printk(KERN_ERR "synaptics_ts_probe: Failed to allocate input device\n");
goto err_input_dev_alloc_failed;
}
ts->input_dev->name = "synaptics-rmi-touchscreen";
set_bit(EV_SYN, ts->input_dev->evbit);
set_bit(EV_KEY, ts->input_dev->evbit);
set_bit(BTN_TOUCH, ts->input_dev->keybit);
set_bit(BTN_2, ts->input_dev->keybit);
set_bit(EV_ABS, ts->input_dev->evbit);
inactive_area_left = inactive_area_left * max_x / 0x10000;
inactive_area_right = inactive_area_right * max_x / 0x10000;
inactive_area_top = inactive_area_top * max_y / 0x10000;
inactive_area_bottom = inactive_area_bottom * max_y / 0x10000;
snap_left_on = snap_left_on * max_x / 0x10000;
snap_left_off = snap_left_off * max_x / 0x10000;
snap_right_on = snap_right_on * max_x / 0x10000;
snap_right_off = snap_right_off * max_x / 0x10000;
snap_top_on = snap_top_on * max_y / 0x10000;
snap_top_off = snap_top_off * max_y / 0x10000;
snap_bottom_on = snap_bottom_on * max_y / 0x10000;
snap_bottom_off = snap_bottom_off * max_y / 0x10000;
fuzz_x = fuzz_x * max_x / 0x10000;
fuzz_y = fuzz_y * max_y / 0x10000;
ts->snap_down[!!(ts->flags & SYNAPTICS_SWAP_XY)] = -inactive_area_left;
ts->snap_up[!!(ts->flags & SYNAPTICS_SWAP_XY)] = max_x + inactive_area_right;
ts->snap_down[!(ts->flags & SYNAPTICS_SWAP_XY)] = -inactive_area_top;
ts->snap_up[!(ts->flags & SYNAPTICS_SWAP_XY)] = max_y + inactive_area_bottom;
ts->snap_down_on[!!(ts->flags & SYNAPTICS_SWAP_XY)] = snap_left_on;
ts->snap_down_off[!!(ts->flags & SYNAPTICS_SWAP_XY)] = snap_left_off;
ts->snap_up_on[!!(ts->flags & SYNAPTICS_SWAP_XY)] = max_x - snap_right_on;
ts->snap_up_off[!!(ts->flags & SYNAPTICS_SWAP_XY)] = max_x - snap_right_off;
ts->snap_down_on[!(ts->flags & SYNAPTICS_SWAP_XY)] = snap_top_on;
ts->snap_down_off[!(ts->flags & SYNAPTICS_SWAP_XY)] = snap_top_off;
ts->snap_up_on[!(ts->flags & SYNAPTICS_SWAP_XY)] = max_y - snap_bottom_on;
ts->snap_up_off[!(ts->flags & SYNAPTICS_SWAP_XY)] = max_y - snap_bottom_off;
printk(KERN_INFO "synaptics_ts_probe: max_x %d, max_y %d\n", max_x, max_y);
printk(KERN_INFO "synaptics_ts_probe: inactive_x %d %d, inactive_y %d %d\n",
inactive_area_left, inactive_area_right,
inactive_area_top, inactive_area_bottom);
printk(KERN_INFO "synaptics_ts_probe: snap_x %d-%d %d-%d, snap_y %d-%d %d-%d\n",
snap_left_on, snap_left_off, snap_right_on, snap_right_off,
snap_top_on, snap_top_off, snap_bottom_on, snap_bottom_off);
input_set_abs_params(ts->input_dev, ABS_X, -inactive_area_left, max_x + inactive_area_right, fuzz_x, 0);
input_set_abs_params(ts->input_dev, ABS_Y, -inactive_area_top, max_y + inactive_area_bottom, fuzz_y, 0);
input_set_abs_params(ts->input_dev, ABS_PRESSURE, 0, 255, fuzz_p, 0);
input_set_abs_params(ts->input_dev, ABS_TOOL_WIDTH, 0, 15, fuzz_w, 0);
input_set_abs_params(ts->input_dev, ABS_HAT0X, -inactive_area_left, max_x + inactive_area_right, fuzz_x, 0);
input_set_abs_params(ts->input_dev, ABS_HAT0Y, -inactive_area_top, max_y + inactive_area_bottom, fuzz_y, 0);
input_set_abs_params(ts->input_dev, ABS_MT_POSITION_X, -inactive_area_left, max_x + inactive_area_right, fuzz_x, 0);
input_set_abs_params(ts->input_dev, ABS_MT_POSITION_Y, -inactive_area_top, max_y + inactive_area_bottom, fuzz_y, 0);
input_set_abs_params(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0, 255, fuzz_p, 0);
input_set_abs_params(ts->input_dev, ABS_MT_WIDTH_MAJOR, 0, 15, fuzz_w, 0);
/* ts->input_dev->name = ts->keypad_info->name; */
ret = input_register_device(ts->input_dev);
if (ret) {
printk(KERN_ERR "synaptics_ts_probe: Unable to register %s input device\n", ts->input_dev->name);
goto err_input_register_device_failed;
}
if (client->irq) {
ret = request_irq(client->irq, synaptics_ts_irq_handler, irqflags, client->name, ts);
if (ret == 0) {
ret = i2c_smbus_write_byte_data(ts->client, 0xf1, 0x01); /* enable abs int */
if (ret)
free_irq(client->irq, ts);
}
if (ret == 0)
ts->use_irq = 1;
else
dev_err(&client->dev, "request_irq failed\n");
}
if (!ts->use_irq) {
hrtimer_init(&ts->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
ts->timer.function = synaptics_ts_timer_func;
hrtimer_start(&ts->timer, ktime_set(1, 0), HRTIMER_MODE_REL);
}
#ifdef CONFIG_HAS_EARLYSUSPEND
ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
ts->early_suspend.suspend = synaptics_ts_early_suspend;
ts->early_suspend.resume = synaptics_ts_late_resume;
register_early_suspend(&ts->early_suspend);
#endif
printk(KERN_INFO "synaptics_ts_probe: Start touchscreen %s in %s mode\n", ts->input_dev->name, ts->use_irq ? "interrupt" : "polling");
return 0;
err_input_register_device_failed:
input_free_device(ts->input_dev);
err_input_dev_alloc_failed:
err_detect_failed:
err_power_failed:
kfree(ts);
err_alloc_data_failed:
err_check_functionality_failed:
return ret;
}
static int synaptics_ts_remove(struct i2c_client *client)
{
struct synaptics_ts_data *ts = i2c_get_clientdata(client);
unregister_early_suspend(&ts->early_suspend);
if (ts->use_irq)
free_irq(client->irq, ts);
else
hrtimer_cancel(&ts->timer);
input_unregister_device(ts->input_dev);
kfree(ts);
return 0;
}
static int synaptics_ts_suspend(struct i2c_client *client, pm_message_t mesg)
{
int ret;
struct synaptics_ts_data *ts = i2c_get_clientdata(client);
if (ts->use_irq)
disable_irq(client->irq);
else
hrtimer_cancel(&ts->timer);
ret = cancel_work_sync(&ts->work);
if (ret && ts->use_irq) /* if work was pending disable-count is now 2 */
enable_irq(client->irq);
ret = i2c_smbus_write_byte_data(ts->client, 0xf1, 0); /* disable interrupt */
if (ret < 0)
printk(KERN_ERR "synaptics_ts_suspend: i2c_smbus_write_byte_data failed\n");
ret = i2c_smbus_write_byte_data(client, 0xf0, 0x86); /* deep sleep */
if (ret < 0)
printk(KERN_ERR "synaptics_ts_suspend: i2c_smbus_write_byte_data failed\n");
if (ts->power) {
ret = ts->power(0);
if (ret < 0)
printk(KERN_ERR "synaptics_ts_resume power off failed\n");
}
return 0;
}
static int synaptics_ts_resume(struct i2c_client *client)
{
int ret;
struct synaptics_ts_data *ts = i2c_get_clientdata(client);
if (ts->power) {
ret = ts->power(1);
if (ret < 0)
printk(KERN_ERR "synaptics_ts_resume power on failed\n");
}
synaptics_init_panel(ts);
if (ts->use_irq)
enable_irq(client->irq);
if (!ts->use_irq)
hrtimer_start(&ts->timer, ktime_set(1, 0), HRTIMER_MODE_REL);
else
i2c_smbus_write_byte_data(ts->client, 0xf1, 0x01); /* enable abs int */
return 0;
}
#ifdef CONFIG_HAS_EARLYSUSPEND
static void synaptics_ts_early_suspend(struct early_suspend *h)
{
struct synaptics_ts_data *ts;
ts = container_of(h, struct synaptics_ts_data, early_suspend);
synaptics_ts_suspend(ts->client, PMSG_SUSPEND);
}
static void synaptics_ts_late_resume(struct early_suspend *h)
{
struct synaptics_ts_data *ts;
ts = container_of(h, struct synaptics_ts_data, early_suspend);
synaptics_ts_resume(ts->client);
}
#endif
static const struct i2c_device_id synaptics_ts_id[] = {
{ SYNAPTICS_I2C_RMI_NAME, 0 },
{ }
};
static struct i2c_driver synaptics_ts_driver = {
.probe = synaptics_ts_probe,
.remove = synaptics_ts_remove,
#ifndef CONFIG_HAS_EARLYSUSPEND
.suspend = synaptics_ts_suspend,
.resume = synaptics_ts_resume,
#endif
.id_table = synaptics_ts_id,
.driver = {
.name = SYNAPTICS_I2C_RMI_NAME,
},
};
static int __devinit synaptics_ts_init(void)
{
synaptics_wq = create_singlethread_workqueue("synaptics_wq");
if (!synaptics_wq)
return -ENOMEM;
return i2c_add_driver(&synaptics_ts_driver);
}
static void __exit synaptics_ts_exit(void)
{
i2c_del_driver(&synaptics_ts_driver);
if (synaptics_wq)
destroy_workqueue(synaptics_wq);
}
module_init(synaptics_ts_init);
module_exit(synaptics_ts_exit);
MODULE_DESCRIPTION("Synaptics Touchscreen Driver");
MODULE_LICENSE("GPL");
Click to expand...
Click to collapse
Maybe we can tweak only the .icl file, or we'll have to dig deep into the kernel to improve the responsiveness of this touch screen!
Increased the sensitivity by changing the value:
touch.pressure.scale = 0.01 to touch.pressure.scale = 0.001
in /system/usr/idc/synaptics-rmi-touchscreen.idc
Please use the Q&A Forum for questions Thanks
Moving to Q&A
dferreira said:
Increased the sensitivity by changing the value:
touch.pressure.scale = 0.01 to touch.pressure.scale = 0.001
in /system/usr/idc/synaptics-rmi-touchscreen.idc
Click to expand...
Click to collapse
I just tried this on my MyTouch 4G Slide (htc Doubleshot) running CyanogenMod 10 (20130101). It either works beautifully or it's my imagination. Thanks!!!!!
Screen Sensitivity Enhancement
GandalfTW said:
Does anyone have any information about how to adjust screen sensitivity under Android, specifricaly Froyo on Nexus One?
I'm trying to research this topic but there seems to be very little information about this. I can't find any tool, script or custom rom that would allow screen sensitivity to be adjusted.
I found a thread talking about doing it for Liqid's touch using script but that's about it. I took a look on the script and I can't move forward with it as the path's script uses do not exists in my Nexus One. If anyone has any experience with this please share. The goal is to make the screen more sensitive then it is as a default.
Thanks.
Thread reference above:
android.modaco.com/content-page/309503/increase-touch-screen-sensitivity-only-tested-on-liquide-1-100-05-based-roms/page/40/
Script:
#!/system/bin/sh
sensitivity=25
noise=25
echo "set sensitivity to $sensitivity"
echo $sensitivity > /sys/devices/platform/i2c-adapter/i2c-0/0-005c/sensitivity
echo "set noise to $noise"
echo $noise > /sys/devices/platform/i2c-adapter/i2c-0/0-005c/noise
echo "done"
Click to expand...
Click to collapse
The easiest way you can change your screen sensitivity is by using Screen Booster apps from Google Play. Its really works dude
So let's say I did this and now my screen doesn't work. How can I get it back?
found new method
worked for my zte v9800
Go to System and find build.prop
Then copy the bellow lines and just paste in bulid.prop
# Touch screen calibration and scroll responsiveness
debug.performance.tuning=1
windowsmgr.max_events_per_sec=200
view.touch_slop=2
view.scroll_friction=1.5
view.minimum_fling_velocity=25
ro.max.fling_velocity=12000
ro.min.fling_velocity=8000
ro.min_pointer_dur=8
touch.size.calibration=geometric
touch.size.scale=100
#touch.size.bias=70
touch.pressure.calibration=amplitude
touch.pressure.scale=0.3
Hello,
I have been struggling with an issue related to v4l enabling in Android Kernel. Please suggest me appropriate place to post my question i found this email for contacting on linux-media website. I am trying to connect external UVC camera with android device.
What i have done so far , I enabled v4l configuration in kernel and i do see in log UVC driver get loaded after enabling as well as video_device_register return 0 and picked up video node 0. But what is the problem is when i application trying to access /dev/video0 it always shows device busy can not open.
I have tried all permutation combination by assigning 0666 permission in init.rc , init.<board>.rc or uevetd.<board>.rc .
But no luck please guide me how can i do it ? I am trying with Logitech C270 webcam and it does support v4l.
Kernel is 3.0.31 and Device is Galaxy Nexus
Thank you
kill $( lsof |grep /dev/video|awk '{print $2}')
kill $( lsof |grep /dev/video*|awk '{print $2}')
---------- Post added at 04:29 PM ---------- Previous post was at 04:16 PM ----------
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <getopt.h> /* getopt_long() */
#include <fcntl.h> /* low-level i/o */
#include <unistd.h>
#include <errno.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <linux/videodev2.h>
#define CLEAR(x) memset(&(x), 0, sizeof(x))
enum io_method {
IO_METHOD_READ,
IO_METHOD_MMAP,
IO_METHOD_USERPTR,
};
struct buffer {
void *start;
size_t length;
};
static char *dev_name;
static enum io_method io = IO_METHOD_MMAP;
static int fd = -1;
struct buffer *buffers;
static unsigned int n_buffers;
static int out_buf;
static int force_format;
static int frame_count = 70;
static void errno_exit(const char *s)
{
fprintf(stderr, "43 %s error %d, %s\n", s, errno, strerror(errno));
exit(EXIT_FAILURE);
}
static int xioctl(int fh, int request, void *arg)
{
int r;
do {
r = ioctl(fh, request, arg);
} while (-1 == r && EINTR == errno);
return r;
}
//process_image(数据指针,大小)
static void process_image(const void *p, int size)
{
if (out_buf)
fwrite(p, size, 1, stdout);
fflush(stderr);
fprintf(stderr, ".");
fflush(stdout);
}
static int read_frame(void)
{
struct v4l2_buffer buf;
unsigned int i;
switch (io) {
case IO_METHOD_READ:
if (-1 == read(fd, buffers[0].start, buffers[0].length)) {
switch (errno) {
case EAGAIN:
return 0;
case EIO:
/* Could ignore EIO, see spec. */
/* fall through */
default:
errno_exit("read");
}
}
process_image(buffers[0].start, buffers[0].length);
break;
case IO_METHOD_MMAP:
CLEAR(buf);
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
buf.memory = V4L2_MEMORY_MMAP;
if (-1 == xioctl(fd, VIDIOC_DQBUF, &buf)) {
switch (errno) {
case EAGAIN:
return 0;
case EIO:
/* Could ignore EIO, see spec. */
/* fall through */
default:
errno_exit("VIDIOC_DQBUF");
}
}
assert(buf.index < n_buffers);
process_image(buffers[buf.index].start, buf.bytesused);
if (-1 == xioctl(fd, VIDIOC_QBUF, &buf))
errno_exit("VIDIOC_QBUF");
break;
case IO_METHOD_USERPTR:
CLEAR(buf);
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
buf.memory = V4L2_MEMORY_USERPTR;
if (-1 == xioctl(fd, VIDIOC_DQBUF, &buf)) {
switch (errno) {
case EAGAIN:
return 0;
case EIO:
/* Could ignore EIO, see spec. */
/* fall through */
default:
errno_exit("VIDIOC_DQBUF");
}
}
for (i = 0; i < n_buffers; ++i)
if (buf.m.userptr == (unsigned long)buffers.start
&& buf.length == buffers.length)
break;
assert(i < n_buffers);
process_image((void *)buf.m.userptr, buf.bytesused);
if (-1 == xioctl(fd, VIDIOC_QBUF, &buf))
errno_exit("VIDIOC_QBUF");
break;
}
return 1;
}
static void mainloop(void)
{
unsigned int count;
count = frame_count;
while (count-- > 0) {
for (; {
fd_set fds;
struct timeval tv;
int r;
FD_ZERO(&fds);
FD_SET(fd, &fds);
/* Timeout. */
tv.tv_sec = 2;
tv.tv_usec = 0;
r = select(fd + 1, &fds, NULL, NULL, &tv);
if (-1 == r) {
if (EINTR == errno)
continue;
errno_exit("select");
}
if (0 == r) {
fprintf(stderr, "190 select timeout\n");
exit(EXIT_FAILURE);
}
if (read_frame())
break;
/* EAGAIN - continue select loop. */
}
}
}
//VIDIOC_STREAMOFF
static void stop_capturing(void)
{
enum v4l2_buf_type type;
switch (io) {
case IO_METHOD_READ:
/* Nothing to do. */
break;
case IO_METHOD_MMAP:
case IO_METHOD_USERPTR:
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if (-1 == xioctl(fd, VIDIOC_STREAMOFF, &type))
errno_exit("VIDIOC_STREAMOFF");
break;
}
}
//VIDIOC_STREAMON
static void start_capturing(void)
{
unsigned int i;
enum v4l2_buf_type type;
switch (io) {
case IO_METHOD_READ:
/* Nothing to do. */
break;
case IO_METHOD_MMAP:
for (i = 0; i < n_buffers; ++i) {
struct v4l2_buffer buf;
CLEAR(buf);
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
buf.memory = V4L2_MEMORY_MMAP;
buf.index = i;
if (-1 == xioctl(fd, VIDIOC_QBUF, &buf))
errno_exit("VIDIOC_QBUF");
}
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if (-1 == xioctl(fd, VIDIOC_STREAMON, &type))
errno_exit("VIDIOC_STREAMON");
break;
case IO_METHOD_USERPTR:
for (i = 0; i < n_buffers; ++i) {
struct v4l2_buffer buf;
CLEAR(buf);
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
buf.memory = V4L2_MEMORY_USERPTR;
buf.index = i;
buf.m.userptr = (unsigned long)buffers.start;
buf.length = buffers.length;
if (-1 == xioctl(fd, VIDIOC_QBUF, &buf))
errno_exit("VIDIOC_QBUF");
}
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if (-1 == xioctl(fd, VIDIOC_STREAMON, &type))
errno_exit("VIDIOC_STREAMON");
break;
}
}
//释放申请的内存
static void uninit_device(void)
{
unsigned int i;
switch (io) {
case IO_METHOD_READ:
free(buffers[0].start);
break;
case IO_METHOD_MMAP:
for (i = 0; i < n_buffers; ++i)
if (-1 == munmap(buffers.start, buffers.length))
errno_exit("munmap");
break;
case IO_METHOD_USERPTR:
for (i = 0; i < n_buffers; ++i)
free(buffers.start);
break;
}
free(buffers);
}
static void init_read(unsigned int buffer_size)
{
buffers = calloc(1, sizeof(*buffers));
if (!buffers) {
fprintf(stderr, "302 Out of memory\n");
exit(EXIT_FAILURE);
}
buffers[0].length = buffer_size;
buffers[0].start = malloc(buffer_size);
if (!buffers[0].start) {
fprintf(stderr, "310 Out of memory\n");
exit(EXIT_FAILURE);
}
}
static void init_mmap(void)
{
struct v4l2_requestbuffers req;
CLEAR(req);
req.count = 4;
req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
req.memory = V4L2_MEMORY_MMAP;
if (-1 == xioctl(fd, VIDIOC_REQBUFS, &req)) {
if (EINVAL == errno) {
fprintf(stderr, "327 %s does not support "
"memory mappingn", dev_name);
exit(EXIT_FAILURE);
} else {
errno_exit("VIDIOC_REQBUFS");
}
}
if (req.count < 2) {
fprintf(stderr, "336 Insufficient buffer memory on %s\n",
dev_name);
exit(EXIT_FAILURE);
}
buffers = calloc(req.count, sizeof(*buffers));
if (!buffers) {
fprintf(stderr, "344 Out of memory\n");
exit(EXIT_FAILURE);
}
for (n_buffers = 0; n_buffers < req.count; ++n_buffers) {
struct v4l2_buffer buf;
CLEAR(buf);
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
buf.memory = V4L2_MEMORY_MMAP;
buf.index = n_buffers;
if (-1 == xioctl(fd, VIDIOC_QUERYBUF, &buf))
errno_exit("VIDIOC_QUERYBUF");
buffers[n_buffers].length = buf.length;
buffers[n_buffers].start =
mmap(NULL /* start anywhere */,
buf.length,
PROT_READ | PROT_WRITE /* required */,
MAP_SHARED /* recommended */,
fd, buf.m.offset);
if (MAP_FAILED == buffers[n_buffers].start)
errno_exit("mmap");
}
}
static void init_userp(unsigned int buffer_size)
{
struct v4l2_requestbuffers req;
CLEAR(req);
req.count = 4;
req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
req.memory = V4L2_MEMORY_USERPTR;
if (-1 == xioctl(fd, VIDIOC_REQBUFS, &req)) {
if (EINVAL == errno) {
fprintf(stderr, "385 %@s does not support "
"user pointer i/on", dev_name);
exit(EXIT_FAILURE);
} else {
errno_exit("VIDIOC_REQBUFS");
}
}
buffers = calloc(4, sizeof(*buffers));
if (!buffers) {
fprintf(stderr, "396 Out of memory\n");
exit(EXIT_FAILURE);
}
for (n_buffers = 0; n_buffers < 4; ++n_buffers) {
buffers[n_buffers].length = buffer_size;
buffers[n_buffers].start = malloc(buffer_size);
if (!buffers[n_buffers].start) {
fprintf(stderr, "405 Out of memory\n");
exit(EXIT_FAILURE);
}
}
}
static void init_device(void)
{
struct v4l2_capability cap;
struct v4l2_cropcap cropcap;
struct v4l2_crop crop;
struct v4l2_format fmt;
unsigned int min;
if (-1 == xioctl(fd, VIDIOC_QUERYCAP, &cap)) {
if (EINVAL == errno) {
fprintf(stderr, "421 @%s is no V4L2 device\n",
dev_name);
exit(EXIT_FAILURE);
} else {
errno_exit("VIDIOC_QUERYCAP");
}
}
if (!(cap.capabilities & V4L2_CAP_VIDEO_CAPTURE)) {
fprintf(stderr, "430 %s is no video capture device\n",
dev_name);
exit(EXIT_FAILURE);
}
switch (io) {
case IO_METHOD_READ:
if (!(cap.capabilities & V4L2_CAP_READWRITE)) {
fprintf(stderr, "438 %s does not support read i/o\n",
dev_name);
exit(EXIT_FAILURE);
}
break;
case IO_METHOD_MMAP:
case IO_METHOD_USERPTR:
if (!(cap.capabilities & V4L2_CAP_STREAMING)) {
fprintf(stderr, "447 %s does not support streaming i/o\n",
dev_name);
exit(EXIT_FAILURE);
}
break;
}
/* Select video input, video standard and tune here. */
CLEAR(cropcap);
cropcap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if (0 == xioctl(fd, VIDIOC_CROPCAP, &cropcap)) {
crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
crop.c = cropcap.defrect; /* reset to default */
if (-1 == xioctl(fd, VIDIOC_S_CROP, &crop)) {
switch (errno) {
case EINVAL:
/* Cropping not supported. */
break;
default:
/* Errors ignored. */
break;
}
}
} else {
/* Errors ignored. */
}
CLEAR(fmt);
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if (force_format) {
fmt.fmt.pix.width = 640;
fmt.fmt.pix.height = 480;
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV;
fmt.fmt.pix.field = V4L2_FIELD_INTERLACED;
if (-1 == xioctl(fd, VIDIOC_S_FMT, &fmt))
errno_exit("VIDIOC_S_FMT");
/* Note VIDIOC_S_FMT may change width and height. */
} else {
/* Preserve original settings as set by v4l2-ctl for example */
if (-1 == xioctl(fd, VIDIOC_G_FMT, &fmt))
errno_exit("VIDIOC_G_FMT");
}
/* Buggy driver paranoia. */
min = fmt.fmt.pix.width * 2;
if (fmt.fmt.pix.bytesperline < min)
fmt.fmt.pix.bytesperline = min;
min = fmt.fmt.pix.bytesperline * fmt.fmt.pix.height;
if (fmt.fmt.pix.sizeimage < min)
fmt.fmt.pix.sizeimage = min;
switch (io) {
case IO_METHOD_READ:
init_read(fmt.fmt.pix.sizeimage);
break;
case IO_METHOD_MMAP:
init_mmap();
break;
case IO_METHOD_USERPTR:
init_userp(fmt.fmt.pix.sizeimage);
break;
}
}
static void close_device(void)
{
if (-1 == close(fd))
errno_exit("close");
fd = -1;
}
static void open_device(void)
{
struct stat st;
if (-1 == stat(dev_name, &st)) {
fprintf(stderr, "536 Cannot identify '%s': %d, %s\n",
dev_name, errno, strerror(errno));
exit(EXIT_FAILURE);
}
if (!S_ISCHR(st.st_mode)) {
fprintf(stderr, "542 %s is no devicen", dev_name);
exit(EXIT_FAILURE);
}
fd = open(dev_name, O_RDWR /* required */ | O_NONBLOCK, 0);
if (-1 == fd) {
fprintf(stderr, "548 Cannot open '%s': %d, %s\n",
dev_name, errno, strerror(errno));
exit(EXIT_FAILURE);
}
}
static void usage(FILE *fp, int argc, char **argv)
{
fprintf(fp,
"Usage: %s [options]\n\n"
"Version 1.3\n"
"Options:\n"
"-d | --device name Video device name [%s]n"
"-h | --help Print this messagen"
"-m | --mmap Use memory mapped buffers [default]n"
"-r | --read Use read() callsn"
"-u | --userp Use application allocated buffersn"
"-o | --output Outputs stream to stdoutn"
"-f | --format Force format to 640x480 YUYVn"
"-c | --count Number of frames to grab [%i]n"
"",
argv[0], dev_name, frame_count);
}
static const char short_options[] = "d:hmruofc:";
static const struct option
long_options[] = {
{ "device", required_argument, NULL, 'd' },
{ "help", no_argument, NULL, 'h' },
{ "mmap", no_argument, NULL, 'm' },
{ "read", no_argument, NULL, 'r' },
{ "userp", no_argument, NULL, 'u' },
{ "output", no_argument, NULL, 'o' },
{ "format", no_argument, NULL, 'f' },
{ "count", required_argument, NULL, 'c' },
{ 0, 0, 0, 0 }
};
int main(int argc, char **argv)
{
dev_name = "/dev/video0";
for (; {
int idx;
int c;
c = getopt_long(argc, argv,
short_options, long_options, &idx);
if (-1 == c)
break;
switch (c) {
case 0: /* getopt_long() flag */
break;
case 'd':
dev_name = optarg;
break;
case 'h':
usage(stdout, argc, argv);
exit(EXIT_SUCCESS);
case 'm':
io = IO_METHOD_MMAP;
break;
case 'r':
io = IO_METHOD_READ;
break;
case 'u':
io = IO_METHOD_USERPTR;
break;
case 'o':
out_buf++;
break;
case 'f':
force_format++;
break;
case 'c':
errno = 0;
frame_count = strtol(optarg, NULL, 0);
if (errno)
errno_exit(optarg);
break;
default:
usage(stderr, argc, argv);
exit(EXIT_FAILURE);
}
}
open_device();
init_device();
start_capturing();
mainloop();
stop_capturing();
uninit_device();
close_device();
fprintf(stderr, "\n");
return 0;
}
[email protected]:/data # gcc /sdcard/camera.c
[email protected]:/data #
[email protected]:/data # ./a.out
43 VIDIOC_QUERYCAP error 25, Not a typewriter
Hi everybody!
I wrote simple server on android with NDK, which will work on port 8888 on android emulator, but i can't connect to it from my client on the host machine.
I added <uses-permission android:name="android.permission.INTERNET"/> in manifest.
I tried to make redirection with telnet:
telnet localhost 5554
redir add tcp:6666:8888
Here code of server:
#include <string.h>
#include <jni.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
jstring
Java_com_example_hellojni_HelloJni_stringFromJNI( JNIEnv* env,
jobject thiz )
{
int socket_desc , client_sock , c , read_size;
struct sockaddr_in server , client;
char* client_message;
int LEN = 512;
client_message = "I am android server";
socket_desc = socket(AF_INET , SOCK_STREAM , 0);
if (socket_desc == -1)
{
return (*env)->NewStringUTF(env, "Could not create socket");
}
server.sin_family = AF_INET;
server.sin_addr.s_addr = INADDR_ANY;
server.sin_port = htons( 8888 );
if( bind(socket_desc,(struct sockaddr *)&server , sizeof(server)) < 0)
{
return (*env)->NewStringUTF(env, "bind failed. Error");
}
listen(socket_desc , 3);
c = sizeof(struct sockaddr_in);
client_sock = accept(socket_desc, (struct sockaddr *)&client, (socklen_t*)&c);
if (client_sock < 0)
{
return (*env)->NewStringUTF(env, "accept failed");
}
while( (read_size = recv(client_sock , buf , 2*LEN+1 , 0)) > 0 )
{
write(client_sock , client_message , strlen(client_message));
}
if(read_size == 0)
{
return (*env)->NewStringUTF(env, "Client disconnected");
}
else if(read_size == -1)
{
return (*env)->NewStringUTF(env, "recv failed");
}
return (*env)->NewStringUTF(env, "Server closed");
}
And code of client on host machine:
#include "stdafx.h"
#include <winsock2.h>
#include <windows.h>
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <stdio.h>
#include <conio.h>
#include <iostream>
#pragma comment(lib, "Ws2_32.lib")
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int host_port= 6666;
char* host_name= "localhost";
unsigned short wVersionRequested;
WSADATA wsaData;
int err;
wVersionRequested = MAKEWORD( 2, 2 );
err = WSAStartup( wVersionRequested, &wsaData );
if ( err != 0 || ( LOBYTE( wsaData.wVersion ) != 2 ||
HIBYTE( wsaData.wVersion ) != 2 )) {
fprintf(stderr, "Could not find useable sock dll %d\n",WSAGetLastError());
return 0;
}
int hsock;
int * p_int ;
hsock = socket(AF_INET, SOCK_STREAM, 0);
if(hsock == -1){
printf("Error initializing socket %d\n",WSAGetLastError());
return 0;
}
p_int = (int*)malloc(sizeof(int));
*p_int = 1;
if( (setsockopt(hsock, SOL_SOCKET, SO_REUSEADDR, (char*)p_int, sizeof(int)) == -1 )||
(setsockopt(hsock, SOL_SOCKET, SO_KEEPALIVE, (char*)p_int, sizeof(int)) == -1 ) ){
printf("Error setting options %d\n", WSAGetLastError());
free(p_int);
return 0;
}
free(p_int);
struct sockaddr_in my_addr;
my_addr.sin_family = AF_INET ;
my_addr.sin_port = htons(host_port);
memset(&(my_addr.sin_zero), 0, 8);
my_addr.sin_addr.s_addr = inet_addr(host_name);
cout<<"client ready\n";
if( connect( hsock, (struct sockaddr*)&my_addr, sizeof(my_addr)) == SOCKET_ERROR ){
fprintf(stderr, "Error connecting socket %d\n", WSAGetLastError()); getchar();
return 0;
}
cout<<"connected to server\n";
char buffer[1024];
int buffer_len = 1024;
int bytecount;
int c;
memset(buffer, '\0', buffer_len);
for(char* p=buffer ; (c=getch())!=13 ; p++){
printf("%c", c);
*p = c;
}
if( (bytecount=send(hsock, buffer, strlen(buffer),0))==SOCKET_ERROR){
fprintf(stderr, "Error sending data %d\n", WSAGetLastError());
return 0;
}
printf("Sent bytes %d\n", bytecount);
if((bytecount = recv(hsock, buffer, buffer_len, 0))==SOCKET_ERROR){
fprintf(stderr, "Error receiving data %d\n", WSAGetLastError());
return 0;
}
printf("Recieved bytes %d\nReceived string \"%s\"\n", bytecount, buffer);
closesocket(hsock);
return 0;
}
Solved!
I happend because my windows firewall blocked this port (in my case 6666) and client couldn't connect to server on emulator
to unlock port in windows - open firewall extra options and add rule for income connections (free for all)
Trying to build a kernel from source for ZTE Vec 4G(msm8226 with 4G), but I'm getting an error I don't know how to fix.
I've already fixed some, as I have quiet a bit of C/C++ knowledge, but not this one:
Code:
CC drivers/media/platform/msm/vidc/msm_venc.o
drivers/media/platform/msm/vidc/msm_venc.c: In function 'try_set_ctrl':
drivers/media/platform/msm/vidc/msm_venc.c:1331: error: unknown field 'val' specified in initializer
drivers/media/platform/msm/vidc/msm_venc.c:1405: error: unknown field 'val' specified in initializer
Case that contains the first error line:
Code:
case V4L2_CID_MPEG_VIDC_VIDEO_NUM_P_FRAMES:
{
int num_p, num_b;
[COLOR="Red"]struct v4l2_ctrl update_ctrl = {.id = 0, .val = 0};[/COLOR]
if (ctrl->id == V4L2_CID_MPEG_VIDEO_H264_I_PERIOD &&
inst->fmts[CAPTURE_PORT]->fourcc != V4L2_PIX_FMT_H264 &&
inst->fmts[CAPTURE_PORT]->fourcc !=
V4L2_PIX_FMT_H264_NO_SC) {
dprintk(VIDC_ERR, "Control 0x%x only valid for H264",
ctrl->id);
rc = -ENOTSUPP;
break;
}
temp_ctrl = TRY_GET_CTRL(V4L2_CID_MPEG_VIDC_VIDEO_NUM_B_FRAMES);
num_b = temp_ctrl->val;
temp_ctrl = TRY_GET_CTRL(V4L2_CID_MPEG_VIDC_VIDEO_NUM_P_FRAMES);
num_p = temp_ctrl->val;
/* V4L2_CID_MPEG_VIDEO_H264_I_PERIOD and _NUM_P_FRAMES are
* implicitly tied to each other. If either is adjusted,
* the other needs to be adjusted in a complementary manner.
* Ideally we adjust _NUM_B_FRAMES as well but we'll leave it
* alone for now */
if (ctrl->id == V4L2_CID_MPEG_VIDEO_H264_I_PERIOD) {
num_p = ctrl->val - 1 - num_b;
update_ctrl.id = V4L2_CID_MPEG_VIDC_VIDEO_NUM_P_FRAMES;
update_ctrl.val = num_p;
} else if (ctrl->id == V4L2_CID_MPEG_VIDC_VIDEO_NUM_P_FRAMES) {
num_p = ctrl->val;
update_ctrl.id = V4L2_CID_MPEG_VIDEO_H264_I_PERIOD;
update_ctrl.val = num_p + num_b;
} else if (ctrl->id == V4L2_CID_MPEG_VIDC_VIDEO_NUM_B_FRAMES) {
num_b = ctrl->val;
update_ctrl.id = V4L2_CID_MPEG_VIDEO_H264_I_PERIOD;
update_ctrl.val = num_p + num_b;
}
if (update_ctrl.id) {
temp_ctrl = TRY_GET_CTRL(update_ctrl.id);
temp_ctrl->val = update_ctrl.val;
}
if (num_b) {
u32 max_num_b_frames = MAX_NUM_B_FRAMES;
property_id = HAL_PARAM_VENC_MAX_NUM_B_FRAMES;
pdata = &max_num_b_frames;
rc = call_hfi_op(hdev, session_set_property,
(void *)inst->session, property_id, pdata);
if (rc) {
dprintk(VIDC_ERR,
"Failed : Setprop MAX_NUM_B_FRAMES %d",
rc);
break;
}
}
property_id = HAL_CONFIG_VENC_INTRA_PERIOD;
intra_period.pframes = num_p;
intra_period.bframes = num_b;
pdata = &intra_period;
break;
}
Code:
case V4L2_CID_MPEG_VIDEO_BITRATE_MODE:
{
int final_mode = 0;
[COLOR="Red"]struct v4l2_ctrl update_ctrl = {.id = 0, .val = 0};[/COLOR]
/* V4L2_CID_MPEG_VIDEO_BITRATE_MODE and _RATE_CONTROL
* manipulate the same thing. If one control's state
* changes, try to mirror the state in the other control's
* value */
if (ctrl->id == V4L2_CID_MPEG_VIDEO_BITRATE_MODE) {
if (ctrl->val == V4L2_MPEG_VIDEO_BITRATE_MODE_VBR) {
final_mode = HAL_RATE_CONTROL_VBR_CFR;
update_ctrl.val =
V4L2_CID_MPEG_VIDC_VIDEO_RATE_CONTROL_VBR_CFR;
} else {/* ...if (ctrl->val == _BITRATE_MODE_CBR) */
final_mode = HAL_RATE_CONTROL_CBR_CFR;
update_ctrl.val =
V4L2_CID_MPEG_VIDC_VIDEO_RATE_CONTROL_CBR_CFR;
}
update_ctrl.id = V4L2_CID_MPEG_VIDC_VIDEO_RATE_CONTROL;
} else if (ctrl->id == V4L2_CID_MPEG_VIDC_VIDEO_RATE_CONTROL) {
switch (ctrl->val) {
case V4L2_CID_MPEG_VIDC_VIDEO_RATE_CONTROL_OFF:
case V4L2_CID_MPEG_VIDC_VIDEO_RATE_CONTROL_VBR_VFR:
case V4L2_CID_MPEG_VIDC_VIDEO_RATE_CONTROL_VBR_CFR:
update_ctrl.val =
V4L2_MPEG_VIDEO_BITRATE_MODE_VBR;
case V4L2_CID_MPEG_VIDC_VIDEO_RATE_CONTROL_CBR_VFR:
case V4L2_CID_MPEG_VIDC_VIDEO_RATE_CONTROL_CBR_CFR:
update_ctrl.val =
V4L2_MPEG_VIDEO_BITRATE_MODE_CBR;
}
final_mode = ctrl->val;
update_ctrl.id = V4L2_CID_MPEG_VIDEO_BITRATE_MODE;
}
if (update_ctrl.id) {
temp_ctrl = TRY_GET_CTRL(update_ctrl.id);
temp_ctrl->val = update_ctrl.val;
}
property_id = HAL_PARAM_VENC_RATE_CONTROL;
property_val = final_mode;
pdata = &property_val;
break;
}
Function calls:
Code:
for (c = 0; c < ctrl->ncontrols; ++c) {
if (ctrl->cluster[c]->is_new) {
struct v4l2_ctrl *temp = ctrl->cluster[c];
[COLOR="Red"]rc = try_set_ctrl(inst, temp);[/COLOR]
if (rc) {
dprintk(VIDC_ERR, "Failed setting %s (%x)",
v4l2_ctrl_get_name(temp->id),
temp->id);
break;
}
}
}
Whole file attached.
From the error, I can tell that .val isn't declared, or something similar, but I need help from an expert to fix it.
Faced with same problem for Alcatel OT Fire E 6015X. My solution:
- Install Android NDK (ArchLinux):
Code:
pacman -S android-ndk
- Add path:
Code:
export PATH=/opt/android-ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin:${PATH}
- Run build:
Code:
make CROSS_COMPILE=arm-linux-androideabi- ARCH=arm zImage
need to replace every .val for .cur.val, the problem is that the val variable is declared within a union named cur inside the v4l2_ctrl structure. So in order for the Compiler to recognize it should be addressed thru the union var
Hello
Please help.
Here is the code of the line in the application
It is necessary to enter 6 digits in the application in the line. And the application only allows 4.
What parameter in the code should be changed ?
package glovoapp.delivery.detail.pickup.upload.quiero;
import android.content.Context;
import android.support.v4.media.a;
import android.text.Editable;
import android.text.InputFilter;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.glovoapp.theme.Palette;
import g3.b;
import glovoapp.delivery.crossdocking.databinding.PriceEditTextBinding;
import glovoapp.utils.l;
import hu.e;
import hu.j;
import java.util.Arrays;
import java.util.List;
import java.util.ListIterator;
import java.util.Locale;
import kotlin.Metadata;
import kotlin.collections.CollectionsKt;
import kotlin.jvm.JvmOverloads;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.SourceDebugExtension;
import kotlin.jvm.internal.StringCompanionObject;
import kotlin.text.Regex;
import kotlin.text.StringsKt;
import t3.a;
@Metadata(d1 = {"\u0000f\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\t\n\u0002\u0018\u0002\n\u0002\u0010\u000b\n\u0002\b\b\n\u0002\u0010\u0006\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\r\n\u0002\u0010\u000e\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\f\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0002\b\r\b\u0007\u0018\u0000 D2\u00020\u0001:\u0004DEFGB%\b\u0007\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\n\b\u0002\u0010\u0004\u001a\u0004\u0018\u00010\u0005\u0012\b\b\u0002\u0010\u0006\u001a\u00020\u0007¢\u0006\u0002\u0010\bJ\u0018\u00104\u001a\u00020\u00152\u0006\u00105\u001a\u0002062\u0006\u00107\u001a\u000208H\u0002J\u0010\u00109\u001a\u00020\u00152\u0006\u00105\u001a\u000206H\u0002J\b\u0010:\u001a\u00020;H\u0014J\u0010\u0010<\u001a\u00020;2\u0006\u0010*\u001a\u00020\u001eH\u0002J\b\u0010=\u001a\u00020;H\u0002J\b\u0010>\u001a\u00020;H\u0002J\u0010\u0010?\u001a\u00020;2\u0006\[email protected]\u001a\u00020\u0015H\u0016J\b\u0010A\u001a\u00020;H\u0002J\u0010\u0010B\u001a\u00020;2\u0006\u0010C\u001a\u00020\u0015H\u0002R\u0011\u0010\t\u001a\u00020\n¢\u0006\b\n\u0000\u001a\u0004\b\u000b\u0010\fR$\u0010\u000e\u001a\u00020\u00072\u0006\u0010\r\u001a\u00020\[email protected]\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u000f\u0010\u0010\"\u0004\b\u0011\u0010\u0012R\u0012\u0010\u0013\u001a\u00060\u0014R\u00020\u0000X\u0082\u0004¢\u0006\u0002\n\u0000R$\u0010\u0016\u001a\u00020\u00152\u0006\u0010\r\u001a\u00020\[email protected]\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0017\u0010\u0018\"\u0004\b\u0019\u0010\u001aR\u0010\u0010\u001b\u001a\u00020\u00078\u0002X\u0083\u0004¢\u0006\u0002\n\u0000R\u0010\u0010\u001c\u001a\u00020\u00078\u0002X\u0083\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u001d\u001a\u00020\u001eX\u0082\u000e¢\u0006\u0002\n\u0000R$\u0010\u001f\u001a\u00020\u00072\u0006\u0010\r\u001a\u00020\[email protected]\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b \u0010\u0010\"\u0004\b!\u0010\u0012R\u0012\u0010\"\u001a\u00060#R\u00020\u0000X\u0082\u0004¢\u0006\u0002\n\u0000R\u001c\u0010$\u001a\u0004\u0018\u00010%X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b&\u0010'\"\u0004\b(\u0010)R$\u0010*\u001a\u00020\u001e2\u0006\u0010\r\u001a\u00020\[email protected]\u0086\u000e¢\u0006\f\u001a\u0004\b+\u0010,\"\u0004\b-\u0010.R\u0010\u0010/\u001a\u00020\u00078\u0002X\u0083\u0004¢\u0006\u0002\n\u0000R\u001e\u00100\u001a\u00020\u00152\u0006\u0010\r\u001a\u00020\[email protected]\u0082\u000e¢\u0006\b\n\u0000\"\u0004\b1\u0010\u001aR\u000e\u00102\u001a\u000203X\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006H"}, d2 = {"Lglovoapp/delivery/detail/pickup/upload/quiero/PriceEditText;", "Landroid/widget/LinearLayout;", "context", "Landroid/content/Context;", "attrs", "Landroid/util/AttributeSet;", "defStyleAttr", "", "(Landroid/content/Context;Landroid/util/AttributeSet;I)V", "binding", "Lglovoapp/delivery/crossdocking/databinding/PriceEditTextBinding;", "getBinding", "()Lglovoapp/delivery/crossdocking/databinding/PriceEditTextBinding;", "value", "decimalDigits", "getDecimalDigits", "()I", "setDecimalDigits", "(I)V", "decimalTextWatcher", "Lglovoapp/delivery/detail/pickup/upload/quiero/PriceEditText$DecimalTextWatcher;", "", "errorEnabled", "getErrorEnabled", "()Z", "setErrorEnabled", "(Z)V", "grayColor", "greenColor", "innerPrice", "", "integerDigits", "getIntegerDigits", "setIntegerDigits", "integerTextWatcher", "Lglovoapp/delivery/detail/pickup/upload/quiero/PriceEditText$IntegerTextWatcher;", "onPriceChangeListener", "Lglovoapp/delivery/detail/pickup/upload/quiero/PriceEditText$OnPriceChangeListener;", "getOnPriceChangeListener", "()Lglovoapp/delivery/detail/pickup/upload/quiero/PriceEditText$OnPriceChangeListener;", "setOnPriceChangeListener", "(Lglovoapp/delivery/detail/pickup/upload/quiero/PriceEditText$OnPriceChangeListenerV", "price", "getPrice", "()D", "setPrice", "(D)V", "redColor", "shouldShowDecimals", "setShouldShowDecimals", "zeroChar", "", "checkDecimalPointEvent", "s", "Landroid/text/Editable;", "char", "", "checkEmptyInteger", "onFinishInflate", "", "onPriceSet", "onPriceTextChanged", "setEditTextsError", "setEnabled", "enabled", "setUnderlineError", "setUnderlineState", "focused", "Companion", "DecimalTextWatcher", "IntegerTextWatcher", "OnPriceChangeListener", "delivery-crossdocking_release"}, k = 1, mv = {1, 8, PriceEditText.$stable}, xi = 48)
@SourceDebugExtension({"SMAP\nPriceEditText.kt\nKotlin\n*S Kotlin\n*F\n+ 1 PriceEditText.kt\nglovoapp/delivery/detail/pickup/upload/quiero/PriceEditText\n+ 2 View.kt\nandroidx/core/view/ViewKt\n+ 3 _Collections.kt\nkotlin/collections/CollectionsKt___CollectionsKt\n+ 4 ArraysJVM.kt\nkotlin/collections/ArraysKt__ArraysJVMKt\n*L\n1#1,317:1\n262#2,2:318\n731#3,9:320\n37#4,2:329\n*S KotlinDebug\n*F\n+ 1 PriceEditText.kt\nglovoapp/delivery/detail/pickup/upload/quiero/PriceEditText\n*L\n47#1:318,2\n229#1:320,9\n230#1:329,2\n*E\n"})
/* loaded from: C:\Users\Diren\AppData\Local\Temp\jadx-18309976577588970056.dex */
public final class PriceEditText extends LinearLayout {
private static final int DEFAULT_DECIMAL_DIGITS = 2;
private static final int DEFAULT_INTEGER_DIGITS = 6;
private final PriceEditTextBinding binding;
private int decimalDigits;
private final DecimalTextWatcher decimalTextWatcher;
private boolean errorEnabled;
private final int grayColor;
private final int greenColor;
private double innerPrice;
private int integerDigits;
private final IntegerTextWatcher integerTextWatcher;
private OnPriceChangeListener onPriceChangeListener;
private final int redColor;
private boolean shouldShowDecimals;
private final String zeroChar;
public static final Companion Companion = new Companion((DefaultConstructorMarker) null);
public static final int $stable = 8;
/* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
@JvmOverloads
public PriceEditText(Context context) {
this(context, null, 0, DEFAULT_INTEGER_DIGITS, null);
Intrinsics.checkNotNullParameter(context, "context");
}
/* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
@JvmOverloads
public PriceEditText(Context context, AttributeSet attributeSet) {
this(context, attributeSet, 0, 4, null);
Intrinsics.checkNotNullParameter(context, "context");
}
public /* synthetic */ PriceEditText(Context context, AttributeSet attributeSet, int i, int i2, DefaultConstructorMarker defaultConstructorMarker) {
this(context, (i2 & DEFAULT_DECIMAL_DIGITS) != 0 ? null : attributeSet, (i2 & 4) != 0 ? 0 : i);
}
/* JADX INFO: Access modifiers changed from: private */
public final boolean checkDecimalPointEvent(Editable s, char r5) {
int o = StringsKt.o(s, r5, 0, false, (int) DEFAULT_INTEGER_DIGITS);
if (o == -1) {
return false;
}
this.binding.editTextInteger.setText(StringsKt.removeRange(s, o, o + 1), TextView.BufferType.NORMAL);
if (!this.shouldShowDecimals) {
EditText editText = this.binding.editTextInteger;
Intrinsics.checkNotNullExpressionValue(editText, "binding.editTextInteger");
l.a(editText);
return true;
}
this.binding.editTextDecimal.requestFocus();
this.binding.editTextDecimal.setSelection(0);
return true;
}
/* JADX INFO: Access modifiers changed from: private */
public final boolean checkEmptyInteger(Editable s) {
if (StringsKt.isBlank(s)) {
Intrinsics.checkNotNullExpressionValue(this.binding.editTextDecimal.getText(), "binding.editTextDecimal.text");
if ((!StringsKt.isBlank(r3)) != false && this.shouldShowDecimals) {
this.integerTextWatcher.byDisabling(new checkEmptyInteger.1(this));
EditText editText = this.binding.editTextInteger;
Intrinsics.checkNotNullExpressionValue(editText, "binding.editTextInteger");
l.a(editText);
return true;
}
return false;
}
return false;
}
/* JADX INFO: Access modifiers changed from: private */
public static final void onFinishInflate$lambda$0(PriceEditText priceEditText, View view, boolean z) {
boolean z2;
Intrinsics.checkNotNullParameter(priceEditText, "this$0");
if (!z && !priceEditText.binding.editTextDecimal.hasFocus()) {
z2 = false;
} else {
z2 = true;
}
priceEditText.setUnderlineState(z2);
}
/* JADX INFO: Access modifiers changed from: private */
public static final boolean onFinishInflate$lambda$1(PriceEditText priceEditText, View view, int i, KeyEvent keyEvent) {
boolean z;
Intrinsics.checkNotNullParameter(priceEditText, "this$0");
if (i == 22 && keyEvent.getAction() == 0) {
EditText editText = priceEditText.binding.editTextInteger;
Intrinsics.checkNotNullExpressionValue(editText, "binding.editTextInteger");
int length = priceEditText.binding.editTextInteger.getText().length();
Intrinsics.checkNotNullParameter(editText, "<this>");
if (editText.getSelectionStart() == length && editText.getSelectionEnd() == length) {
z = true;
} else {
z = false;
}
if (z) {
priceEditText.binding.editTextDecimal.requestFocus();
priceEditText.binding.editTextDecimal.setSelection(0);
return true;
}
}
return false;
}
/* JADX INFO: Access modifiers changed from: private */
public static final void onFinishInflate$lambda$2(PriceEditText priceEditText, View view, boolean z) {
boolean z2;
Intrinsics.checkNotNullParameter(priceEditText, "this$0");
boolean z3 = false;
if (!z && !priceEditText.binding.editTextInteger.hasFocus()) {
z2 = false;
} else {
z2 = true;
}
priceEditText.setUnderlineState(z2);
if (z) {
Editable text = priceEditText.binding.editTextInteger.getText();
if (text == null || text.length() == 0) {
z3 = true;
}
if (z3) {
priceEditText.binding.editTextInteger.setText(priceEditText.zeroChar, TextView.BufferType.NORMAL);
}
}
}
/* JADX INFO: Access modifiers changed from: private */
public static final boolean onFinishInflate$lambda$3(PriceEditText priceEditText, View view, int i, KeyEvent keyEvent) {
boolean z;
Intrinsics.checkNotNullParameter(priceEditText, "this$0");
if ((i == 67 || i == 21) && keyEvent.getAction() == 0) {
EditText editText = priceEditText.binding.editTextDecimal;
Intrinsics.checkNotNullExpressionValue(editText, "binding.editTextDecimal");
Intrinsics.checkNotNullParameter(editText, "<this>");
if (editText.getSelectionStart() == 0 && editText.getSelectionEnd() == 0) {
z = true;
} else {
z = false;
}
if (z) {
priceEditText.binding.editTextInteger.requestFocus();
EditText editText2 = priceEditText.binding.editTextInteger;
Intrinsics.checkNotNullExpressionValue(editText2, "binding.editTextInteger");
l.a(editText2);
return true;
}
}
return false;
}
private final void onPriceSet(double price) {
boolean z;
List emptyList;
boolean z2;
boolean z3;
if (price == 0.0d) {
z = true;
} else {
z = false;
}
if (z) {
this.integerTextWatcher.byDisabling(new onPriceSet.1(this));
this.decimalTextWatcher.byDisabling(new onPriceSet.2(this));
OnPriceChangeListener onPriceChangeListener = this.onPriceChangeListener;
if (onPriceChangeListener != null) {
onPriceChangeListener.onPriceChanged(price);
return;
}
return;
}
StringCompanionObject stringCompanionObject = StringCompanionObject.INSTANCE;
String format = String.format(Locale.US, b.g("%.", this.decimalDigits, "f"), Arrays.copyOf(new Object[]{Double.valueOf(price)}, 1));
Intrinsics.checkNotNullExpressionValue(format, "format(locale, format, *args)");
List split = new Regex("\\.").split(StringsKt.x(format, ',', '.'), 0);
if (!split.isEmpty()) {
ListIterator listIterator = split.listIterator(split.size());
while (listIterator.hasPrevious()) {
if (((String) listIterator.previous()).length() == 0) {
z3 = true;
} else {
z3 = false;
}
if (!z3) {
emptyList = CollectionsKt.take(split, listIterator.nextIndex() + 1);
break;
}
}
}
emptyList = CollectionsKt.emptyList();
String[] strArr = (String[]) emptyList.toArray(new String[0]);
if (strArr.length == 0) {
z2 = true;
} else {
z2 = false;
}
if ((!z2) != false) {
this.integerTextWatcher.byDisabling(new onPriceSet.3(this, strArr[0]));
}
if (strArr.length > 1) {
this.decimalTextWatcher.byDisabling(new onPriceSet.4(this, strArr[1]));
}
OnPriceChangeListener onPriceChangeListener2 = this.onPriceChangeListener;
if (onPriceChangeListener2 != null) {
onPriceChangeListener2.onPriceChanged(price);
}
}
/* JADX INFO: Access modifiers changed from: private */
public final void onPriceTextChanged() {
int i;
double d;
String obj = this.binding.editTextInteger.getText().toString();
String obj2 = this.binding.editTextDecimal.getText().toString();
Integer intOrNull = StringsKt.toIntOrNull(obj);
int i2 = 0;
if (intOrNull != null) {
i = intOrNull.intValue();
} else {
i = 0;
}
Integer intOrNull2 = StringsKt.toIntOrNull(obj2);
if (intOrNull2 != null) {
i2 = intOrNull2.intValue();
}
Double doubleOrNull = StringsKt.toDoubleOrNull(i + "." + i2);
if (doubleOrNull != null) {
d = doubleOrNull.doubleValue();
} else {
d = 0.0d;
}
this.innerPrice = d;
OnPriceChangeListener onPriceChangeListener = this.onPriceChangeListener;
if (onPriceChangeListener != null) {
onPriceChangeListener.onPriceChanged(d);
}
}
private final void setEditTextsError() {
int i;
if (this.errorEnabled) {
i = this.redColor;
} else {
i = this.greenColor;
}
this.binding.editTextInteger.setTextColor(i);
this.binding.editTextDecimal.setTextColor(i);
}
private final void setShouldShowDecimals(boolean z) {
int i;
this.shouldShowDecimals = z;
EditText editText = this.binding.editTextDecimal;
Intrinsics.checkNotNullExpressionValue(editText, "binding.editTextDecimal");
if (z) {
i = 0;
} else {
i = 8;
}
editText.setVisibility(i);
if (!z) {
this.binding.editTextInteger.requestFocus();
EditText editText2 = this.binding.editTextInteger;
Intrinsics.checkNotNullExpressionValue(editText2, "binding.editTextInteger");
l.a(editText2);
this.binding.editTextInteger.setTextAlignment(4);
this.binding.editTextDecimal.setText((CharSequence) null);
return;
}
this.binding.editTextInteger.setTextAlignment(3);
}
private final void setUnderlineError() {
setUnderlineState(this.binding.editTextInteger.hasFocus() || this.binding.editTextDecimal.hasFocus());
}
private final void setUnderlineState(boolean focused) {
int i;
ViewGroup.LayoutParams layoutParams = this.binding.underline.getLayoutParams();
View view = this.binding.underline;
if (focused) {
layoutParams.height = getContext().getResources().getDimensionPixelSize(e.underline_height_focused);
i = this.greenColor;
} else {
layoutParams.height = getContext().getResources().getDimensionPixelSize(e.underline_height);
i = this.grayColor;
}
view.setBackgroundColor(i);
if (this.errorEnabled) {
this.binding.underline.setBackgroundColor(this.redColor);
}
this.binding.underline.setLayoutParams(layoutParams);
this.binding.underline.requestLayout();
}
public final PriceEditTextBinding getBinding() {
return this.binding;
}
public final int getDecimalDigits() {
return this.decimalDigits;
}
public final boolean getErrorEnabled() {
return this.errorEnabled;
}
public final int getIntegerDigits() {
return this.integerDigits;
}
public final OnPriceChangeListener getOnPriceChangeListener() {
return this.onPriceChangeListener;
}
/* renamed from: getPrice reason: from getter */
public final double getInnerPrice() {
return this.innerPrice;
}
@override // android.view.View
public void onFinishInflate() {
super.onFinishInflate();
setOrientation(1);
setIntegerDigits(DEFAULT_INTEGER_DIGITS);
setDecimalDigits(DEFAULT_DECIMAL_DIGITS);
this.binding.editTextInteger.addTextChangedListener(this.integerTextWatcher);
this.binding.editTextInteger.setOnFocusChangeListener(new a(this));
this.binding.editTextInteger.setOnKeyListener(new b(this));
this.binding.editTextDecimal.addTextChangedListener(this.decimalTextWatcher);
this.binding.editTextDecimal.setOnFocusChangeListener(new c(this));
this.binding.editTextDecimal.setOnKeyListener(new d(this));
}
public final void setDecimalDigits(int i) {
boolean z;
boolean z2;
if (i >= 0) {
if (this.decimalDigits > i) {
z = true;
} else {
z = false;
}
this.decimalDigits = i;
if (i > 0) {
z2 = true;
} else {
z2 = false;
}
setShouldShowDecimals(z2);
this.binding.editTextDecimal.setFilters(new InputFilter.LengthFilter[]{new InputFilter.LengthFilter(i)});
this.binding.editTextDecimal.setHint(StringsKt.w(this.zeroChar, i));
if (z) {
EditText editText = this.binding.editTextDecimal;
editText.setText(editText.getText());
return;
}
return;
}
throw new IllegalArgumentException(a.b("decimalDigits can't be < 0 but is: ", i));
}
@override // android.view.View
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
this.binding.editTextInteger.setEnabled(enabled);
this.binding.editTextDecimal.setEnabled(enabled);
}
public final void setErrorEnabled(boolean z) {
this.errorEnabled = z;
setEditTextsError();
setUnderlineError();
}
public final void setIntegerDigits(int i) {
if (i >= 0) {
this.integerDigits = i;
this.binding.editTextInteger.setFilters(new InputFilter.LengthFilter[]{new InputFilter.LengthFilter(i)});
return;
}
throw new IllegalArgumentException(a.b("integerDigits can't be < 0 but is: ", i));
}
public final void setOnPriceChangeListener(OnPriceChangeListener onPriceChangeListener) {
this.onPriceChangeListener = onPriceChangeListener;
}
public final void setPrice(double d) {
if (d >= 0.0d) {
this.innerPrice = d;
onPriceSet(d);
return;
}
throw new IllegalArgumentException("price can't be < 0.0 but is: " + d);
}
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
@JvmOverloads
public PriceEditText (контекст контекста, набор атрибутов AttributeSet, int i) {
супер(контекст, набор атрибутов, я);
Intrinsics.checkNotNullParameter(контекст, "контекст");
PriceEditTextBinding inflate = PriceEditTextBinding.inflate(LayoutInflater.from(context), this);
Intrinsics.checkNotNullExpressionValue(inflate, "inflate(LayoutInflater.from(context), this)");
this.binding = раздувать;
Строка строка = context.getString(j.zero);
Intrinsics.checkNotNullExpressionValue(строка, "context.getString(com.gl…app.design.R.string.zero)");
this.zeroChar = строка;
this.integerTextWatcher = новый IntegerTextWatcher (это);
this.decimalTextWatcher = новый DecimalTextWatcher (это);
Палитра палитра = Palette.f;
Объект obj = t3.aa;
this.greenColor = ada (контекст, палитра.c);
this.grayColor = ada(контекст, Palette.wc);
this.redColor = ada(context, Palette.mc);
this.shouldShowDecimals = истина;
this.integerDigits = DEFAULT_INTEGER_DIGITS;
this.decimalDigits = DEFAULT_DECIMAL_DIGITS;
}
}
Ya trying to make us go blind?
Please go back and modify that gobble-dee-gook to be inclosed in [code=java] and [/code]
Also, when you paste that text make sure that it is already /n terminated (i.e. Unix), vs /r/n (i.e. DOS).
Previewing would help too.
Java:
package glovoapp.delivery.detail.pickup.upload.quiero;
import android.content.Context;
import android.support.v4.media.a;
import android.text.Editable;
import android.text.InputFilter;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.glovoapp.theme.Palette;
import g3.b;
import glovoapp.delivery.crossdocking.databinding.PriceEditTextBinding;
import glovoapp.utils.l;
import hu.e;
import hu.j;
import java.util.Arrays;
import java.util.List;
import java.util.ListIterator;
import java.util.Locale;
import kotlin.Metadata;
import kotlin.collections.CollectionsKt;
import kotlin.jvm.JvmOverloads;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.SourceDebugExtension;
import kotlin.jvm.internal.StringCompanionObject;
import kotlin.text.Regex;
import kotlin.text.StringsKt;
import t3.a;
@Metadata(d1 = {"\u0000f\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\t\n\u0002\u0018\u0002\n\u0002\u0010\u000b\n\u0002\b\b\n\u0002\u0010\u0006\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\r\n\u0002\u0010\u000e\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\f\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0002\b\r\b\u0007\u0018\u0000 D2\u00020\u0001:\u0004DEFGB%\b\u0007\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\n\b\u0002\u0010\u0004\u001a\u0004\u0018\u00010\u0005\u0012\b\b\u0002\u0010\u0006\u001a\u00020\u0007¢\u0006\u0002\u0010\bJ\u0018\u00104\u001a\u00020\u00152\u0006\u00105\u001a\u0002062\u0006\u00107\u001a\u000208H\u0002J\u0010\u00109\u001a\u00020\u00152\u0006\u00105\u001a\u000206H\u0002J\b\u0010:\u001a\u00020;H\u0014J\u0010\u0010<\u001a\u00020;2\u0006\u0010*\u001a\u00020\u001eH\u0002J\b\u0010=\u001a\u00020;H\u0002J\b\u0010>\u001a\u00020;H\u0002J\u0010\u0010?\u001a\u00020;2\u0006\[email protected]\u001a\u00020\u0015H\u0016J\b\u0010A\u001a\u00020;H\u0002J\u0010\u0010B\u001a\u00020;2\u0006\u0010C\u001a\u00020\u0015H\u0002R\u0011\u0010\t\u001a\u00020\n¢\u0006\b\n\u0000\u001a\u0004\b\u000b\u0010\fR$\u0010\u000e\u001a\u00020\u00072\u0006\u0010\r\u001a\u00020\[email protected]\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u000f\u0010\u0010\"\u0004\b\u0011\u0010\u0012R\u0012\u0010\u0013\u001a\u00060\u0014R\u00020\u0000X\u0082\u0004¢\u0006\u0002\n\u0000R$\u0010\u0016\u001a\u00020\u00152\u0006\u0010\r\u001a\u00020\[email protected]\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0017\u0010\u0018\"\u0004\b\u0019\u0010\u001aR\u0010\u0010\u001b\u001a\u00020\u00078\u0002X\u0083\u0004¢\u0006\u0002\n\u0000R\u0010\u0010\u001c\u001a\u00020\u00078\u0002X\u0083\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u001d\u001a\u00020\u001eX\u0082\u000e¢\u0006\u0002\n\u0000R$\u0010\u001f\u001a\u00020\u00072\u0006\u0010\r\u001a\u00020\[email protected]\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b \u0010\u0010\"\u0004\b!\u0010\u0012R\u0012\u0010\"\u001a\u00060#R\u00020\u0000X\u0082\u0004¢\u0006\u0002\n\u0000R\u001c\u0010$\u001a\u0004\u0018\u00010%X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b&\u0010'\"\u0004\b(\u0010)R$\u0010*\u001a\u00020\u001e2\u0006\u0010\r\u001a\u00020\[email protected]\u0086\u000e¢\u0006\f\u001a\u0004\b+\u0010,\"\u0004\b-\u0010.R\u0010\u0010/\u001a\u00020\u00078\u0002X\u0083\u0004¢\u0006\u0002\n\u0000R\u001e\u00100\u001a\u00020\u00152\u0006\u0010\r\u001a\u00020\[email protected]\u0082\u000e¢\u0006\b\n\u0000\"\u0004\b1\u0010\u001aR\u000e\u00102\u001a\u000203X\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006H"}, d2 = {"Lglovoapp/delivery/detail/pickup/upload/quiero/PriceEditText;", "Landroid/widget/LinearLayout;", "context", "Landroid/content/Context;", "attrs", "Landroid/util/AttributeSet;", "defStyleAttr", "", "(Landroid/content/Context;Landroid/util/AttributeSet;I)V", "binding", "Lglovoapp/delivery/crossdocking/databinding/PriceEditTextBinding;", "getBinding", "()Lglovoapp/delivery/crossdocking/databinding/PriceEditTextBinding;", "value", "decimalDigits", "getDecimalDigits", "()I", "setDecimalDigits", "(I)V", "decimalTextWatcher", "Lglovoapp/delivery/detail/pickup/upload/quiero/PriceEditText$DecimalTextWatcher;", "", "errorEnabled", "getErrorEnabled", "()Z", "setErrorEnabled", "(Z)V", "grayColor", "greenColor", "innerPrice", "", "integerDigits", "getIntegerDigits", "setIntegerDigits", "integerTextWatcher", "Lglovoapp/delivery/detail/pickup/upload/quiero/PriceEditText$IntegerTextWatcher;", "onPriceChangeListener", "Lglovoapp/delivery/detail/pickup/upload/quiero/PriceEditText$OnPriceChangeListener;", "getOnPriceChangeListener", "()Lglovoapp/delivery/detail/pickup/upload/quiero/PriceEditText$OnPriceChangeListener;", "setOnPriceChangeListener", "(Lglovoapp/delivery/detail/pickup/upload/quiero/PriceEditText$OnPriceChangeListener;)V", "price", "getPrice", "()D", "setPrice", "(D)V", "redColor", "shouldShowDecimals", "setShouldShowDecimals", "zeroChar", "", "checkDecimalPointEvent", "s", "Landroid/text/Editable;", "char", "", "checkEmptyInteger", "onFinishInflate", "", "onPriceSet", "onPriceTextChanged", "setEditTextsError", "setEnabled", "enabled", "setUnderlineError", "setUnderlineState", "focused", "Companion", "DecimalTextWatcher", "IntegerTextWatcher", "OnPriceChangeListener", "delivery-crossdocking_release"}, k = 1, mv = {1, 8, PriceEditText.$stable}, xi = 48)
@SourceDebugExtension({"SMAP\nPriceEditText.kt\nKotlin\n*S Kotlin\n*F\n+ 1 PriceEditText.kt\nglovoapp/delivery/detail/pickup/upload/quiero/PriceEditText\n+ 2 View.kt\nandroidx/core/view/ViewKt\n+ 3 _Collections.kt\nkotlin/collections/CollectionsKt___CollectionsKt\n+ 4 ArraysJVM.kt\nkotlin/collections/ArraysKt__ArraysJVMKt\n*L\n1#1,317:1\n262#2,2:318\n731#3,9:320\n37#4,2:329\n*S KotlinDebug\n*F\n+ 1 PriceEditText.kt\nglovoapp/delivery/detail/pickup/upload/quiero/PriceEditText\n*L\n47#1:318,2\n229#1:320,9\n230#1:329,2\n*E\n"})
/* loaded from: C:\Users\Diren\AppData\Local\Temp\jadx-18309976577588970056.dex */
public final class PriceEditText extends LinearLayout {
private static final int DEFAULT_DECIMAL_DIGITS = 2;
private static final int DEFAULT_INTEGER_DIGITS = 6;
private final PriceEditTextBinding binding;
private int decimalDigits;
private final DecimalTextWatcher decimalTextWatcher;
private boolean errorEnabled;
private final int grayColor;
private final int greenColor;
private double innerPrice;
private int integerDigits;
private final IntegerTextWatcher integerTextWatcher;
private OnPriceChangeListener onPriceChangeListener;
private final int redColor;
private boolean shouldShowDecimals;
private final String zeroChar;
public static final Companion Companion = new Companion((DefaultConstructorMarker) null);
public static final int $stable = 8;
/* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
@JvmOverloads
public PriceEditText(Context context) {
this(context, null, 0, DEFAULT_INTEGER_DIGITS, null);
Intrinsics.checkNotNullParameter(context, "context");
}
/* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
@JvmOverloads
public PriceEditText(Context context, AttributeSet attributeSet) {
this(context, attributeSet, 0, 4, null);
Intrinsics.checkNotNullParameter(context, "context");
}
public /* synthetic */ PriceEditText(Context context, AttributeSet attributeSet, int i, int i2, DefaultConstructorMarker defaultConstructorMarker) {
this(context, (i2 & DEFAULT_DECIMAL_DIGITS) != 0 ? null : attributeSet, (i2 & 4) != 0 ? 0 : i);
}
/* JADX INFO: Access modifiers changed from: private */
public final boolean checkDecimalPointEvent(Editable s, char r5) {
int o = StringsKt.o(s, r5, 0, false, (int) DEFAULT_INTEGER_DIGITS);
if (o == -1) {
return false;
}
this.binding.editTextInteger.setText(StringsKt.removeRange(s, o, o + 1), TextView.BufferType.NORMAL);
if (!this.shouldShowDecimals) {
EditText editText = this.binding.editTextInteger;
Intrinsics.checkNotNullExpressionValue(editText, "binding.editTextInteger");
l.a(editText);
return true;
}
this.binding.editTextDecimal.requestFocus();
this.binding.editTextDecimal.setSelection(0);
return true;
}
/* JADX INFO: Access modifiers changed from: private */
public final boolean checkEmptyInteger(Editable s) {
if (StringsKt.isBlank(s)) {
Intrinsics.checkNotNullExpressionValue(this.binding.editTextDecimal.getText(), "binding.editTextDecimal.text");
if ((!StringsKt.isBlank(r3)) != false && this.shouldShowDecimals) {
this.integerTextWatcher.byDisabling(new checkEmptyInteger.1(this));
EditText editText = this.binding.editTextInteger;
Intrinsics.checkNotNullExpressionValue(editText, "binding.editTextInteger");
l.a(editText);
return true;
}
return false;
}
return false;
}
/* JADX INFO: Access modifiers changed from: private */
public static final void onFinishInflate$lambda$0(PriceEditText priceEditText, View view, boolean z) {
boolean z2;
Intrinsics.checkNotNullParameter(priceEditText, "this$0");
if (!z && !priceEditText.binding.editTextDecimal.hasFocus()) {
z2 = false;
} else {
z2 = true;
}
priceEditText.setUnderlineState(z2);
}
/* JADX INFO: Access modifiers changed from: private */
public static final boolean onFinishInflate$lambda$1(PriceEditText priceEditText, View view, int i, KeyEvent keyEvent) {
boolean z;
Intrinsics.checkNotNullParameter(priceEditText, "this$0");
if (i == 22 && keyEvent.getAction() == 0) {
EditText editText = priceEditText.binding.editTextInteger;
Intrinsics.checkNotNullExpressionValue(editText, "binding.editTextInteger");
int length = priceEditText.binding.editTextInteger.getText().length();
Intrinsics.checkNotNullParameter(editText, "<this>");
if (editText.getSelectionStart() == length && editText.getSelectionEnd() == length) {
z = true;
} else {
z = false;
}
if (z) {
priceEditText.binding.editTextDecimal.requestFocus();
priceEditText.binding.editTextDecimal.setSelection(0);
return true;
}
}
return false;
}
/* JADX INFO: Access modifiers changed from: private */
public static final void onFinishInflate$lambda$2(PriceEditText priceEditText, View view, boolean z) {
boolean z2;
Intrinsics.checkNotNullParameter(priceEditText, "this$0");
boolean z3 = false;
if (!z && !priceEditText.binding.editTextInteger.hasFocus()) {
z2 = false;
} else {
z2 = true;
}
priceEditText.setUnderlineState(z2);
if (z) {
Editable text = priceEditText.binding.editTextInteger.getText();
if (text == null || text.length() == 0) {
z3 = true;
}
if (z3) {
priceEditText.binding.editTextInteger.setText(priceEditText.zeroChar, TextView.BufferType.NORMAL);
}
}
}
/* JADX INFO: Access modifiers changed from: private */
public static final boolean onFinishInflate$lambda$3(PriceEditText priceEditText, View view, int i, KeyEvent keyEvent) {
boolean z;
Intrinsics.checkNotNullParameter(priceEditText, "this$0");
if ((i == 67 || i == 21) && keyEvent.getAction() == 0) {
EditText editText = priceEditText.binding.editTextDecimal;
Intrinsics.checkNotNullExpressionValue(editText, "binding.editTextDecimal");
Intrinsics.checkNotNullParameter(editText, "<this>");
if (editText.getSelectionStart() == 0 && editText.getSelectionEnd() == 0) {
z = true;
} else {
z = false;
}
if (z) {
priceEditText.binding.editTextInteger.requestFocus();
EditText editText2 = priceEditText.binding.editTextInteger;
Intrinsics.checkNotNullExpressionValue(editText2, "binding.editTextInteger");
l.a(editText2);
return true;
}
}
return false;
}
private final void onPriceSet(double price) {
boolean z;
List emptyList;
boolean z2;
boolean z3;
if (price == 0.0d) {
z = true;
} else {
z = false;
}
if (z) {
this.integerTextWatcher.byDisabling(new onPriceSet.1(this));
this.decimalTextWatcher.byDisabling(new onPriceSet.2(this));
OnPriceChangeListener onPriceChangeListener = this.onPriceChangeListener;
if (onPriceChangeListener != null) {
onPriceChangeListener.onPriceChanged(price);
return;
}
return;
}
StringCompanionObject stringCompanionObject = StringCompanionObject.INSTANCE;
String format = String.format(Locale.US, b.g("%.", this.decimalDigits, "f"), Arrays.copyOf(new Object[]{Double.valueOf(price)}, 1));
Intrinsics.checkNotNullExpressionValue(format, "format(locale, format, *args)");
List split = new Regex("\\.").split(StringsKt.x(format, ',', '.'), 0);
if (!split.isEmpty()) {
ListIterator listIterator = split.listIterator(split.size());
while (listIterator.hasPrevious()) {
if (((String) listIterator.previous()).length() == 0) {
z3 = true;
} else {
z3 = false;
}
if (!z3) {
emptyList = CollectionsKt.take(split, listIterator.nextIndex() + 1);
break;
}
}
}
emptyList = CollectionsKt.emptyList();
String[] strArr = (String[]) emptyList.toArray(new String[0]);
if (strArr.length == 0) {
z2 = true;
} else {
z2 = false;
}
if ((!z2) != false) {
this.integerTextWatcher.byDisabling(new onPriceSet.3(this, strArr[0]));
}
if (strArr.length > 1) {
this.decimalTextWatcher.byDisabling(new onPriceSet.4(this, strArr[1]));
}
OnPriceChangeListener onPriceChangeListener2 = this.onPriceChangeListener;
if (onPriceChangeListener2 != null) {
onPriceChangeListener2.onPriceChanged(price);
}
}
/* JADX INFO: Access modifiers changed from: private */
public final void onPriceTextChanged() {
int i;
double d;
String obj = this.binding.editTextInteger.getText().toString();
String obj2 = this.binding.editTextDecimal.getText().toString();
Integer intOrNull = StringsKt.toIntOrNull(obj);
int i2 = 0;
if (intOrNull != null) {
i = intOrNull.intValue();
} else {
i = 0;
}
Integer intOrNull2 = StringsKt.toIntOrNull(obj2);
if (intOrNull2 != null) {
i2 = intOrNull2.intValue();
}
Double doubleOrNull = StringsKt.toDoubleOrNull(i + "." + i2);
if (doubleOrNull != null) {
d = doubleOrNull.doubleValue();
} else {
d = 0.0d;
}
this.innerPrice = d;
OnPriceChangeListener onPriceChangeListener = this.onPriceChangeListener;
if (onPriceChangeListener != null) {
onPriceChangeListener.onPriceChanged(d);
}
}
private final void setEditTextsError() {
int i;
if (this.errorEnabled) {
i = this.redColor;
} else {
i = this.greenColor;
}
this.binding.editTextInteger.setTextColor(i);
this.binding.editTextDecimal.setTextColor(i);
}
private final void setShouldShowDecimals(boolean z) {
int i;
this.shouldShowDecimals = z;
EditText editText = this.binding.editTextDecimal;
Intrinsics.checkNotNullExpressionValue(editText, "binding.editTextDecimal");
if (z) {
i = 0;
} else {
i = 8;
}
editText.setVisibility(i);
if (!z) {
this.binding.editTextInteger.requestFocus();
EditText editText2 = this.binding.editTextInteger;
Intrinsics.checkNotNullExpressionValue(editText2, "binding.editTextInteger");
l.a(editText2);
this.binding.editTextInteger.setTextAlignment(4);
this.binding.editTextDecimal.setText((CharSequence) null);
return;
}
this.binding.editTextInteger.setTextAlignment(3);
}
private final void setUnderlineError() {
setUnderlineState(this.binding.editTextInteger.hasFocus() || this.binding.editTextDecimal.hasFocus());
}
private final void setUnderlineState(boolean focused) {
int i;
ViewGroup.LayoutParams layoutParams = this.binding.underline.getLayoutParams();
View view = this.binding.underline;
if (focused) {
layoutParams.height = getContext().getResources().getDimensionPixelSize(e.underline_height_focused);
i = this.greenColor;
} else {
layoutParams.height = getContext().getResources().getDimensionPixelSize(e.underline_height);
i = this.grayColor;
}
view.setBackgroundColor(i);
if (this.errorEnabled) {
this.binding.underline.setBackgroundColor(this.redColor);
}
this.binding.underline.setLayoutParams(layoutParams);
this.binding.underline.requestLayout();
}
public final PriceEditTextBinding getBinding() {
return this.binding;
}
public final int getDecimalDigits() {
return this.decimalDigits;
}
public final boolean getErrorEnabled() {
return this.errorEnabled;
}
public final int getIntegerDigits() {
return this.integerDigits;
}
public final OnPriceChangeListener getOnPriceChangeListener() {
return this.onPriceChangeListener;
}
/* renamed from: getPrice reason: from getter */
public final double getInnerPrice() {
return this.innerPrice;
}
@override // android.view.View
public void onFinishInflate() {
super.onFinishInflate();
setOrientation(1);
setIntegerDigits(DEFAULT_INTEGER_DIGITS);
setDecimalDigits(DEFAULT_DECIMAL_DIGITS);
this.binding.editTextInteger.addTextChangedListener(this.integerTextWatcher);
this.binding.editTextInteger.setOnFocusChangeListener(new a(this));
this.binding.editTextInteger.setOnKeyListener(new b(this));
this.binding.editTextDecimal.addTextChangedListener(this.decimalTextWatcher);
this.binding.editTextDecimal.setOnFocusChangeListener(new c(this));
this.binding.editTextDecimal.setOnKeyListener(new d(this));
}
public final void setDecimalDigits(int i) {
boolean z;
boolean z2;
if (i >= 0) {
if (this.decimalDigits > i) {
z = true;
} else {
z = false;
}
this.decimalDigits = i;
if (i > 0) {
z2 = true;
} else {
z2 = false;
}
setShouldShowDecimals(z2);
this.binding.editTextDecimal.setFilters(new InputFilter.LengthFilter[]{new InputFilter.LengthFilter(i)});
this.binding.editTextDecimal.setHint(StringsKt.w(this.zeroChar, i));
if (z) {
EditText editText = this.binding.editTextDecimal;
editText.setText(editText.getText());
return;
}
return;
}
throw new IllegalArgumentException(a.b("decimalDigits can't be < 0 but is: ", i));
}
@override // android.view.View
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
this.binding.editTextInteger.setEnabled(enabled);
this.binding.editTextDecimal.setEnabled(enabled);
}
public final void setErrorEnabled(boolean z) {
this.errorEnabled = z;
setEditTextsError();
setUnderlineError();
}
public final void setIntegerDigits(int i) {
if (i >= 0) {
this.integerDigits = i;
this.binding.editTextInteger.setFilters(new InputFilter.LengthFilter[]{new InputFilter.LengthFilter(i)});
return;
}
throw new IllegalArgumentException(a.b("integerDigits can't be < 0 but is: ", i));
}
public final void setOnPriceChangeListener(OnPriceChangeListener onPriceChangeListener) {
this.onPriceChangeListener = onPriceChangeListener;
}
public final void setPrice(double d) {
if (d >= 0.0d) {
this.innerPrice = d;
onPriceSet(d);
return;
}
throw new IllegalArgumentException("price can't be < 0.0 but is: " + d);
}
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
@JvmOverloads
public PriceEditText (контекст контекста, набор атрибутов AttributeSet, int i) {
супер(контекст, набор атрибутов, я);
Intrinsics.checkNotNullParameter(контекст, "контекст");
PriceEditTextBinding inflate = PriceEditTextBinding.inflate(LayoutInflater.from(context), this);
Intrinsics.checkNotNullExpressionValue(inflate, "inflate(LayoutInflater.from(context), this)");
this.binding = раздувать;
Строка строка = context.getString(j.zero);
Intrinsics.checkNotNullExpressionValue(строка, "context.getString(com.gl…app.design.R.string.zero)");
this.zeroChar = строка;
this.integerTextWatcher = новый IntegerTextWatcher (это);
this.decimalTextWatcher = новый DecimalTextWatcher (это);
Палитра палитра = Palette.f;
Объект obj = t3.aa;
this.greenColor = ada (контекст, палитра.c);
this.grayColor = ada(контекст, Palette.wc);
this.redColor = ada(context, Palette.mc);
this.shouldShowDecimals = истина;
this.integerDigits = DEFAULT_INTEGER_DIGITS;
this.decimalDigits = DEFAULT_DECIMAL_DIGITS;
}
}
Renate said:
Java:
package glovoapp.delivery.detail.pickup.upload.quiero;
import android.content.Context;
import android.support.v4.media.a;
import android.text.Editable;
import android.text.InputFilter;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.glovoapp.theme.Palette;
import g3.b;
import glovoapp.delivery.crossdocking.databinding.PriceEditTextBinding;
import glovoapp.utils.l;
import hu.e;
import hu.j;
import java.util.Arrays;
import java.util.List;
import java.util.ListIterator;
import java.util.Locale;
import kotlin.Metadata;
import kotlin.collections.CollectionsKt;
import kotlin.jvm.JvmOverloads;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.SourceDebugExtension;
import kotlin.jvm.internal.StringCompanionObject;
import kotlin.text.Regex;
import kotlin.text.StringsKt;
import t3.a;
@Metadata(d1 = {"\u0000f\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\t\n\u0002\u0018\u0002\n\u0002\u0010\u000b\n\u0002\b\b\n\u0002\u0010\u0006\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\r\n\u0002\u0010\u000e\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\f\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0002\b\r\b\u0007\u0018\u0000 D2\u00020\u0001:\u0004DEFGB%\b\u0007\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\n\b\u0002\u0010\u0004\u001a\u0004\u0018\u00010\u0005\u0012\b\b\u0002\u0010\u0006\u001a\u00020\u0007¢\u0006\u0002\u0010\bJ\u0018\u00104\u001a\u00020\u00152\u0006\u00105\u001a\u0002062\u0006\u00107\u001a\u000208H\u0002J\u0010\u00109\u001a\u00020\u00152\u0006\u00105\u001a\u000206H\u0002J\b\u0010:\u001a\u00020;H\u0014J\u0010\u0010<\u001a\u00020;2\u0006\u0010*\u001a\u00020\u001eH\u0002J\b\u0010=\u001a\u00020;H\u0002J\b\u0010>\u001a\u00020;H\u0002J\u0010\u0010?\u001a\u00020;2\u0006\[email protected]\u001a\u00020\u0015H\u0016J\b\u0010A\u001a\u00020;H\u0002J\u0010\u0010B\u001a\u00020;2\u0006\u0010C\u001a\u00020\u0015H\u0002R\u0011\u0010\t\u001a\u00020\n¢\u0006\b\n\u0000\u001a\u0004\b\u000b\u0010\fR$\u0010\u000e\u001a\u00020\u00072\u0006\u0010\r\u001a\u00020\[email protected]\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u000f\u0010\u0010\"\u0004\b\u0011\u0010\u0012R\u0012\u0010\u0013\u001a\u00060\u0014R\u00020\u0000X\u0082\u0004¢\u0006\u0002\n\u0000R$\u0010\u0016\u001a\u00020\u00152\u0006\u0010\r\u001a\u00020\[email protected]\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0017\u0010\u0018\"\u0004\b\u0019\u0010\u001aR\u0010\u0010\u001b\u001a\u00020\u00078\u0002X\u0083\u0004¢\u0006\u0002\n\u0000R\u0010\u0010\u001c\u001a\u00020\u00078\u0002X\u0083\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u001d\u001a\u00020\u001eX\u0082\u000e¢\u0006\u0002\n\u0000R$\u0010\u001f\u001a\u00020\u00072\u0006\u0010\r\u001a\u00020\[email protected]\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b \u0010\u0010\"\u0004\b!\u0010\u0012R\u0012\u0010\"\u001a\u00060#R\u00020\u0000X\u0082\u0004¢\u0006\u0002\n\u0000R\u001c\u0010$\u001a\u0004\u0018\u00010%X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b&\u0010'\"\u0004\b(\u0010)R$\u0010*\u001a\u00020\u001e2\u0006\u0010\r\u001a\u00020\[email protected]\u0086\u000e¢\u0006\f\u001a\u0004\b+\u0010,\"\u0004\b-\u0010.R\u0010\u0010/\u001a\u00020\u00078\u0002X\u0083\u0004¢\u0006\u0002\n\u0000R\u001e\u00100\u001a\u00020\u00152\u0006\u0010\r\u001a\u00020\[email protected]\u0082\u000e¢\u0006\b\n\u0000\"\u0004\b1\u0010\u001aR\u000e\u00102\u001a\u000203X\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006H"}, d2 = {"Lglovoapp/delivery/detail/pickup/upload/quiero/PriceEditText;", "Landroid/widget/LinearLayout;", "context", "Landroid/content/Context;", "attrs", "Landroid/util/AttributeSet;", "defStyleAttr", "", "(Landroid/content/Context;Landroid/util/AttributeSet;I)V", "binding", "Lglovoapp/delivery/crossdocking/databinding/PriceEditTextBinding;", "getBinding", "()Lglovoapp/delivery/crossdocking/databinding/PriceEditTextBinding;", "value", "decimalDigits", "getDecimalDigits", "()I", "setDecimalDigits", "(I)V", "decimalTextWatcher", "Lglovoapp/delivery/detail/pickup/upload/quiero/PriceEditText$DecimalTextWatcher;", "", "errorEnabled", "getErrorEnabled", "()Z", "setErrorEnabled", "(Z)V", "grayColor", "greenColor", "innerPrice", "", "integerDigits", "getIntegerDigits", "setIntegerDigits", "integerTextWatcher", "Lglovoapp/delivery/detail/pickup/upload/quiero/PriceEditText$IntegerTextWatcher;", "onPriceChangeListener", "Lglovoapp/delivery/detail/pickup/upload/quiero/PriceEditText$OnPriceChangeListener;", "getOnPriceChangeListener", "()Lglovoapp/delivery/detail/pickup/upload/quiero/PriceEditText$OnPriceChangeListener;", "setOnPriceChangeListener", "(Lglovoapp/delivery/detail/pickup/upload/quiero/PriceEditText$OnPriceChangeListener;)V", "price", "getPrice", "()D", "setPrice", "(D)V", "redColor", "shouldShowDecimals", "setShouldShowDecimals", "zeroChar", "", "checkDecimalPointEvent", "s", "Landroid/text/Editable;", "char", "", "checkEmptyInteger", "onFinishInflate", "", "onPriceSet", "onPriceTextChanged", "setEditTextsError", "setEnabled", "enabled", "setUnderlineError", "setUnderlineState", "focused", "Companion", "DecimalTextWatcher", "IntegerTextWatcher", "OnPriceChangeListener", "delivery-crossdocking_release"}, k = 1, mv = {1, 8, PriceEditText.$stable}, xi = 48)
@SourceDebugExtension({"SMAP\nPriceEditText.kt\nKotlin\n*S Kotlin\n*F\n+ 1 PriceEditText.kt\nglovoapp/delivery/detail/pickup/upload/quiero/PriceEditText\n+ 2 View.kt\nandroidx/core/view/ViewKt\n+ 3 _Collections.kt\nkotlin/collections/CollectionsKt___CollectionsKt\n+ 4 ArraysJVM.kt\nkotlin/collections/ArraysKt__ArraysJVMKt\n*L\n1#1,317:1\n262#2,2:318\n731#3,9:320\n37#4,2:329\n*S KotlinDebug\n*F\n+ 1 PriceEditText.kt\nglovoapp/delivery/detail/pickup/upload/quiero/PriceEditText\n*L\n47#1:318,2\n229#1:320,9\n230#1:329,2\n*E\n"})
/* loaded from: C:\Users\Diren\AppData\Local\Temp\jadx-18309976577588970056.dex */
public final class PriceEditText extends LinearLayout {
private static final int DEFAULT_DECIMAL_DIGITS = 2;
private static final int DEFAULT_INTEGER_DIGITS = 6;
private final PriceEditTextBinding binding;
private int decimalDigits;
private final DecimalTextWatcher decimalTextWatcher;
private boolean errorEnabled;
private final int grayColor;
private final int greenColor;
private double innerPrice;
private int integerDigits;
private final IntegerTextWatcher integerTextWatcher;
private OnPriceChangeListener onPriceChangeListener;
private final int redColor;
private boolean shouldShowDecimals;
private final String zeroChar;
public static final Companion Companion = new Companion((DefaultConstructorMarker) null);
public static final int $stable = 8;
/* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
@JvmOverloads
public PriceEditText(Context context) {
this(context, null, 0, DEFAULT_INTEGER_DIGITS, null);
Intrinsics.checkNotNullParameter(context, "context");
}
/* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
@JvmOverloads
public PriceEditText(Context context, AttributeSet attributeSet) {
this(context, attributeSet, 0, 4, null);
Intrinsics.checkNotNullParameter(context, "context");
}
public /* synthetic */ PriceEditText(Context context, AttributeSet attributeSet, int i, int i2, DefaultConstructorMarker defaultConstructorMarker) {
this(context, (i2 & DEFAULT_DECIMAL_DIGITS) != 0 ? null : attributeSet, (i2 & 4) != 0 ? 0 : i);
}
/* JADX INFO: Access modifiers changed from: private */
public final boolean checkDecimalPointEvent(Editable s, char r5) {
int o = StringsKt.o(s, r5, 0, false, (int) DEFAULT_INTEGER_DIGITS);
if (o == -1) {
return false;
}
this.binding.editTextInteger.setText(StringsKt.removeRange(s, o, o + 1), TextView.BufferType.NORMAL);
if (!this.shouldShowDecimals) {
EditText editText = this.binding.editTextInteger;
Intrinsics.checkNotNullExpressionValue(editText, "binding.editTextInteger");
l.a(editText);
return true;
}
this.binding.editTextDecimal.requestFocus();
this.binding.editTextDecimal.setSelection(0);
return true;
}
/* JADX INFO: Access modifiers changed from: private */
public final boolean checkEmptyInteger(Editable s) {
if (StringsKt.isBlank(s)) {
Intrinsics.checkNotNullExpressionValue(this.binding.editTextDecimal.getText(), "binding.editTextDecimal.text");
if ((!StringsKt.isBlank(r3)) != false && this.shouldShowDecimals) {
this.integerTextWatcher.byDisabling(new checkEmptyInteger.1(this));
EditText editText = this.binding.editTextInteger;
Intrinsics.checkNotNullExpressionValue(editText, "binding.editTextInteger");
l.a(editText);
return true;
}
return false;
}
return false;
}
/* JADX INFO: Access modifiers changed from: private */
public static final void onFinishInflate$lambda$0(PriceEditText priceEditText, View view, boolean z) {
boolean z2;
Intrinsics.checkNotNullParameter(priceEditText, "this$0");
if (!z && !priceEditText.binding.editTextDecimal.hasFocus()) {
z2 = false;
} else {
z2 = true;
}
priceEditText.setUnderlineState(z2);
}
/* JADX INFO: Access modifiers changed from: private */
public static final boolean onFinishInflate$lambda$1(PriceEditText priceEditText, View view, int i, KeyEvent keyEvent) {
boolean z;
Intrinsics.checkNotNullParameter(priceEditText, "this$0");
if (i == 22 && keyEvent.getAction() == 0) {
EditText editText = priceEditText.binding.editTextInteger;
Intrinsics.checkNotNullExpressionValue(editText, "binding.editTextInteger");
int length = priceEditText.binding.editTextInteger.getText().length();
Intrinsics.checkNotNullParameter(editText, "<this>");
if (editText.getSelectionStart() == length && editText.getSelectionEnd() == length) {
z = true;
} else {
z = false;
}
if (z) {
priceEditText.binding.editTextDecimal.requestFocus();
priceEditText.binding.editTextDecimal.setSelection(0);
return true;
}
}
return false;
}
/* JADX INFO: Access modifiers changed from: private */
public static final void onFinishInflate$lambda$2(PriceEditText priceEditText, View view, boolean z) {
boolean z2;
Intrinsics.checkNotNullParameter(priceEditText, "this$0");
boolean z3 = false;
if (!z && !priceEditText.binding.editTextInteger.hasFocus()) {
z2 = false;
} else {
z2 = true;
}
priceEditText.setUnderlineState(z2);
if (z) {
Editable text = priceEditText.binding.editTextInteger.getText();
if (text == null || text.length() == 0) {
z3 = true;
}
if (z3) {
priceEditText.binding.editTextInteger.setText(priceEditText.zeroChar, TextView.BufferType.NORMAL);
}
}
}
/* JADX INFO: Access modifiers changed from: private */
public static final boolean onFinishInflate$lambda$3(PriceEditText priceEditText, View view, int i, KeyEvent keyEvent) {
boolean z;
Intrinsics.checkNotNullParameter(priceEditText, "this$0");
if ((i == 67 || i == 21) && keyEvent.getAction() == 0) {
EditText editText = priceEditText.binding.editTextDecimal;
Intrinsics.checkNotNullExpressionValue(editText, "binding.editTextDecimal");
Intrinsics.checkNotNullParameter(editText, "<this>");
if (editText.getSelectionStart() == 0 && editText.getSelectionEnd() == 0) {
z = true;
} else {
z = false;
}
if (z) {
priceEditText.binding.editTextInteger.requestFocus();
EditText editText2 = priceEditText.binding.editTextInteger;
Intrinsics.checkNotNullExpressionValue(editText2, "binding.editTextInteger");
l.a(editText2);
return true;
}
}
return false;
}
private final void onPriceSet(double price) {
boolean z;
List emptyList;
boolean z2;
boolean z3;
if (price == 0.0d) {
z = true;
} else {
z = false;
}
if (z) {
this.integerTextWatcher.byDisabling(new onPriceSet.1(this));
this.decimalTextWatcher.byDisabling(new onPriceSet.2(this));
OnPriceChangeListener onPriceChangeListener = this.onPriceChangeListener;
if (onPriceChangeListener != null) {
onPriceChangeListener.onPriceChanged(price);
return;
}
return;
}
StringCompanionObject stringCompanionObject = StringCompanionObject.INSTANCE;
String format = String.format(Locale.US, b.g("%.", this.decimalDigits, "f"), Arrays.copyOf(new Object[]{Double.valueOf(price)}, 1));
Intrinsics.checkNotNullExpressionValue(format, "format(locale, format, *args)");
List split = new Regex("\\.").split(StringsKt.x(format, ',', '.'), 0);
if (!split.isEmpty()) {
ListIterator listIterator = split.listIterator(split.size());
while (listIterator.hasPrevious()) {
if (((String) listIterator.previous()).length() == 0) {
z3 = true;
} else {
z3 = false;
}
if (!z3) {
emptyList = CollectionsKt.take(split, listIterator.nextIndex() + 1);
break;
}
}
}
emptyList = CollectionsKt.emptyList();
String[] strArr = (String[]) emptyList.toArray(new String[0]);
if (strArr.length == 0) {
z2 = true;
} else {
z2 = false;
}
if ((!z2) != false) {
this.integerTextWatcher.byDisabling(new onPriceSet.3(this, strArr[0]));
}
if (strArr.length > 1) {
this.decimalTextWatcher.byDisabling(new onPriceSet.4(this, strArr[1]));
}
OnPriceChangeListener onPriceChangeListener2 = this.onPriceChangeListener;
if (onPriceChangeListener2 != null) {
onPriceChangeListener2.onPriceChanged(price);
}
}
/* JADX INFO: Access modifiers changed from: private */
public final void onPriceTextChanged() {
int i;
double d;
String obj = this.binding.editTextInteger.getText().toString();
String obj2 = this.binding.editTextDecimal.getText().toString();
Integer intOrNull = StringsKt.toIntOrNull(obj);
int i2 = 0;
if (intOrNull != null) {
i = intOrNull.intValue();
} else {
i = 0;
}
Integer intOrNull2 = StringsKt.toIntOrNull(obj2);
if (intOrNull2 != null) {
i2 = intOrNull2.intValue();
}
Double doubleOrNull = StringsKt.toDoubleOrNull(i + "." + i2);
if (doubleOrNull != null) {
d = doubleOrNull.doubleValue();
} else {
d = 0.0d;
}
this.innerPrice = d;
OnPriceChangeListener onPriceChangeListener = this.onPriceChangeListener;
if (onPriceChangeListener != null) {
onPriceChangeListener.onPriceChanged(d);
}
}
private final void setEditTextsError() {
int i;
if (this.errorEnabled) {
i = this.redColor;
} else {
i = this.greenColor;
}
this.binding.editTextInteger.setTextColor(i);
this.binding.editTextDecimal.setTextColor(i);
}
private final void setShouldShowDecimals(boolean z) {
int i;
this.shouldShowDecimals = z;
EditText editText = this.binding.editTextDecimal;
Intrinsics.checkNotNullExpressionValue(editText, "binding.editTextDecimal");
if (z) {
i = 0;
} else {
i = 8;
}
editText.setVisibility(i);
if (!z) {
this.binding.editTextInteger.requestFocus();
EditText editText2 = this.binding.editTextInteger;
Intrinsics.checkNotNullExpressionValue(editText2, "binding.editTextInteger");
l.a(editText2);
this.binding.editTextInteger.setTextAlignment(4);
this.binding.editTextDecimal.setText((CharSequence) null);
return;
}
this.binding.editTextInteger.setTextAlignment(3);
}
private final void setUnderlineError() {
setUnderlineState(this.binding.editTextInteger.hasFocus() || this.binding.editTextDecimal.hasFocus());
}
private final void setUnderlineState(boolean focused) {
int i;
ViewGroup.LayoutParams layoutParams = this.binding.underline.getLayoutParams();
View view = this.binding.underline;
if (focused) {
layoutParams.height = getContext().getResources().getDimensionPixelSize(e.underline_height_focused);
i = this.greenColor;
} else {
layoutParams.height = getContext().getResources().getDimensionPixelSize(e.underline_height);
i = this.grayColor;
}
view.setBackgroundColor(i);
if (this.errorEnabled) {
this.binding.underline.setBackgroundColor(this.redColor);
}
this.binding.underline.setLayoutParams(layoutParams);
this.binding.underline.requestLayout();
}
public final PriceEditTextBinding getBinding() {
return this.binding;
}
public final int getDecimalDigits() {
return this.decimalDigits;
}
public final boolean getErrorEnabled() {
return this.errorEnabled;
}
public final int getIntegerDigits() {
return this.integerDigits;
}
public final OnPriceChangeListener getOnPriceChangeListener() {
return this.onPriceChangeListener;
}
/* renamed from: getPrice reason: from getter */
public final double getInnerPrice() {
return this.innerPrice;
}
@override // android.view.View
public void onFinishInflate() {
super.onFinishInflate();
setOrientation(1);
setIntegerDigits(DEFAULT_INTEGER_DIGITS);
setDecimalDigits(DEFAULT_DECIMAL_DIGITS);
this.binding.editTextInteger.addTextChangedListener(this.integerTextWatcher);
this.binding.editTextInteger.setOnFocusChangeListener(new a(this));
this.binding.editTextInteger.setOnKeyListener(new b(this));
this.binding.editTextDecimal.addTextChangedListener(this.decimalTextWatcher);
this.binding.editTextDecimal.setOnFocusChangeListener(new c(this));
this.binding.editTextDecimal.setOnKeyListener(new d(this));
}
public final void setDecimalDigits(int i) {
boolean z;
boolean z2;
if (i >= 0) {
if (this.decimalDigits > i) {
z = true;
} else {
z = false;
}
this.decimalDigits = i;
if (i > 0) {
z2 = true;
} else {
z2 = false;
}
setShouldShowDecimals(z2);
this.binding.editTextDecimal.setFilters(new InputFilter.LengthFilter[]{new InputFilter.LengthFilter(i)});
this.binding.editTextDecimal.setHint(StringsKt.w(this.zeroChar, i));
if (z) {
EditText editText = this.binding.editTextDecimal;
editText.setText(editText.getText());
return;
}
return;
}
throw new IllegalArgumentException(a.b("decimalDigits can't be < 0 but is: ", i));
}
@override // android.view.View
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
this.binding.editTextInteger.setEnabled(enabled);
this.binding.editTextDecimal.setEnabled(enabled);
}
public final void setErrorEnabled(boolean z) {
this.errorEnabled = z;
setEditTextsError();
setUnderlineError();
}
public final void setIntegerDigits(int i) {
if (i >= 0) {
this.integerDigits = i;
this.binding.editTextInteger.setFilters(new InputFilter.LengthFilter[]{new InputFilter.LengthFilter(i)});
return;
}
throw new IllegalArgumentException(a.b("integerDigits can't be < 0 but is: ", i));
}
public final void setOnPriceChangeListener(OnPriceChangeListener onPriceChangeListener) {
this.onPriceChangeListener = onPriceChangeListener;
}
public final void setPrice(double d) {
if (d >= 0.0d) {
this.innerPrice = d;
onPriceSet(d);
return;
}
throw new IllegalArgumentException("price can't be < 0.0 but is: " + d);
}
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
@JvmOverloads
public PriceEditText (контекст контекста, набор атрибутов AttributeSet, int i) {
супер(контекст, набор атрибутов, я);
Intrinsics.checkNotNullParameter(контекст, "контекст");
PriceEditTextBinding inflate = PriceEditTextBinding.inflate(LayoutInflater.from(context), this);
Intrinsics.checkNotNullExpressionValue(inflate, "inflate(LayoutInflater.from(context), this)");
this.binding = раздувать;
Строка строка = context.getString(j.zero);
Intrinsics.checkNotNullExpressionValue(строка, "context.getString(com.gl…app.design.R.string.zero)");
this.zeroChar = строка;
this.integerTextWatcher = новый IntegerTextWatcher (это);
this.decimalTextWatcher = новый DecimalTextWatcher (это);
Палитра палитра = Palette.f;
Объект obj = t3.aa;
this.greenColor = ada (контекст, палитра.c);
this.grayColor = ada(контекст, Palette.wc);
this.redColor = ada(context, Palette.mc);
this.shouldShowDecimals = истина;
this.integerDigits = DEFAULT_INTEGER_DIGITS;
this.decimalDigits = DEFAULT_DECIMAL_DIGITS;
}
}
Click to expand...
Click to collapse
I am sorry. But I'm just getting started with java.
How can I understand what needs to be changed in the code?
So that the application does not block the input of more than 4 digits.
You need to be able to enter 6 digits in a line.
Please help me.
I'm willing to pay money for help.
Write me what to do step by step.
Here is the line:
this.binding.editTextDecimal.setFilters(new InputFilter.LengthFilter[]{new InputFilter.LengthFilter(i)});
Where "i" is supposedly 4.
Whoever wrote this code should be shot.
Using a custom LinearLayout with separate integer value and decimal fraction?
With two separate EditText you may be typing to decimals when you think that you're typing to integers.
I can't read the error message in the video.
Renate said:
Whoever wrote this code should be shot.
Using a custom LinearLayout with separate integer value and decimal fraction?
With two separate EditText you may be typing to decimals when you think that you're typing to integers.
I can't read the error message in the video.
Click to expand...
Click to collapse
You don't have to pay attention to the error.
I can `t get it
this.binding.editTextDecimal.setFilters(new InputFilter.LengthFilter[]{new InputFilter.LengthFilter(i)});
(i) is the number the user enters
What needs to be changed in the code? so that the user can enter more than 4 digits
In the smali:
new-array v1, v1, [Landroid/text/InputFilter$LengthFilter;
.line 27
.line 28
new-instance v4, Landroid/text/InputFilter$LengthFilter;
.line 29
.line 30
invoke-direct {v4, p1}, Landroid/text/InputFilter$LengthFilter;-><init>(I)V
.line 31
.line 32
.line 33
aput-object v4, v1, v2
new-array v1, v1, [Landroid/text/InputFilter$LengthFilter;
.line 11
.line 12
new-instance v2, Landroid/text/InputFilter$LengthFilter;
.line 13
.line 14
invoke-direct {v2, p1}, Landroid/text/InputFilter$LengthFilter;-><init>(I)V
.line 15
.line 16
.line 17
How to understand which line is responsible for integer values and which for decimal fraction?
What does <init> stand for in code?
And in the byte code, I did not figure out where the limit on the numeric value (I) is set
.smali
direngetpc said:
You don't have to pay attention to the error.
Click to expand...
Click to collapse
You're right. I don't have to.
Renate wanders off and reads a book...