In order for your inputs to be acted upon immediately, you have to get rid of those delay() functions and just track elapsed time. Look at the Blink Without Delay example in the IDE (File->examples->02.Digital->Blink Without Delay). You should also debounce your inputs and detect when a switch changes state, not just what state it is in. File->Examples->02.Digital->State Change Detection.
Then, you get something like this (untested):
(and you didn't say if you have pullup resistors on those inputs)
const int RELAY_PIN = A5; // the Arduino pin, which connects to the IN pin of relay
const int inputPin_1 = 2;
const int inputPin_2 = 3;
unsigned long lastTimerTime;
const unsigned long onPeriod = 1500; // on time in milliseconds
const unsigned long offPeriod = 2500;
unsigned long cyclePeriod;
bool isCycleOn = false;
int prevVal_1;
int prevVal_2;
enum { RELAY_OFF, RELAY_ON, RELAY_CYCLE };
int state;
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin A5 as an output
pinMode(RELAY_PIN, OUTPUT);
digitalWrite( RELAY_PIN, LOW );
state = RELAY_OFF;
pinMode(inputPin_1, INPUT);
pinMode(inputPin_2, INPUT);
prevVal_1 = digitalRead(inputPin_1);
prevVal_2 = digitalRead(inputPin_2);
}
void loop() {
// read pins to see if anything has changed
int Val_1 = digitalRead(inputPin_1);
int Val_2 = digitalRead(inputPin_2);
int oldState = state;
/*
read inputs and update state
and debounce any pin changes so relay
doesn't toggle back and forth
*/
if (Val_1 != prevVal_1) {
// switch one has changed state
if (Val_1 == LOW) {
// relay is off
state = RELAY_OFF;
}
else {
// relay depends on Val_2, assume normal
state = RELAY_CYCLE;
}
delay(20); // debounce switch 1
prevVal_1 = Val_1;
}
if (Val_2 != prevVal_2) {
// switch two has changed state
if (Val_2 == LOW) {
// normal relay cycling
state = RELAY_CYCLE;
}
else {
// relay always on
state = RELAY_ON;
}
delay(20); // debounce switch 2
prevVal_2 = Val_2;
}
/*
if the state has changed, do anything
required to start the new state
*/
if ( state != oldState ) {
switch (state) {
case RELAY_OFF:
digitalWrite(RELAY_PIN, LOW);
break;
case RELAY_ON:
digitalWrite(RELAY_PIN, HIGH);
break;
case RELAY_CYCLE:
digitalWrite(RELAY_PIN, HIGH);
lastTimerTime = millis();
isCycleOn = true;
cyclePeriod = onPeriod;
}
}
/*
Update based on elapsed time and state we are in
*/
switch (state) {
case RELAY_OFF:
// nothing more to do
break;
case RELAY_ON:
// nothing more to do
break;
case RELAY_CYCLE:
if ( millis() - lastTimerTime >= cyclePeriod ) {
// time to toggle the relay
lastTimerTime = millis();
if (isCycleOn) {
cyclePeriod = offPeriod;
digitalWrite(RELAY_PIN, LOW);
isCycleOn = false;
}
else {
cyclePeriod = onPeriod;
digitalWrite(RELAY_PIN, HIGH);
isCycleOn = true;
}
}
}
}