Skip to content

Commit

Permalink
Merge pull request #123 from RoadXY/master
Browse files Browse the repository at this point in the history
Widgets - extract strings
  • Loading branch information
galadril committed Dec 24, 2015
2 parents b6cbd69 + d58a751 commit 7fee089
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import nl.hnogames.domoticz.Domoticz.Domoticz;
import nl.hnogames.domoticz.Interfaces.DevicesReceiver;
import nl.hnogames.domoticz.Interfaces.setCommandReceiver;
import nl.hnogames.domoticz.R;
import nl.hnogames.domoticz.Utils.SharedPrefUtil;

public class WidgetIntentReceiver extends BroadcastReceiver {
Expand Down Expand Up @@ -132,7 +133,7 @@ public void onReceiveDevice(DevicesInfo s) {

@Override
public void onError(Exception error) {
Toast.makeText(context, "Failed to toggling switch.", Toast.LENGTH_SHORT).show();
Toast.makeText(context, R.string.failed_toggeling_switch, Toast.LENGTH_SHORT).show();
}
}, idx);
}
Expand All @@ -143,13 +144,13 @@ public void onBlindClick(final DevicesInfo clickedSwitch, int jsonAction, Domoti
mDomoticz.setAction(idx, jsonUrl, jsonAction, 0, new setCommandReceiver() {
@Override
public void onReceiveResult(String result) {
Toast.makeText(context, "Switch toggled: " + clickedSwitch.getName(), Toast.LENGTH_SHORT).show();
Toast.makeText(context, context.getString(R.string.switch_toggled) + ": " + clickedSwitch.getName(), Toast.LENGTH_SHORT).show();
updateWidget(context);
}

@Override
public void onError(Exception error) {
Toast.makeText(context, "Failed to toggle switch." + widgetID, Toast.LENGTH_SHORT).show();
Toast.makeText(context, context.getString(R.string.failed_toggeling_switch), Toast.LENGTH_SHORT).show();
}
});
}
Expand All @@ -171,13 +172,13 @@ public void onButtonClick(final DevicesInfo clickedSwitch, boolean checked, Domo
mDomoticz.setAction(idx, jsonUrl, jsonAction, 0, new setCommandReceiver() {
@Override
public void onReceiveResult(String result) {
Toast.makeText(context, "Switch toggled: " + clickedSwitch.getName() , Toast.LENGTH_SHORT).show();
Toast.makeText(context, context.getString(R.string.switch_toggled) + ": " + clickedSwitch.getName() , Toast.LENGTH_SHORT).show();
updateWidget(context);
}

@Override
public void onError(Exception error) {
Toast.makeText(context, "Failed to toggle switch." + widgetID, Toast.LENGTH_SHORT).show();
Toast.makeText(context, context.getString(R.string.failed_toggeling_switch), Toast.LENGTH_SHORT).show();
}
});
}
Expand Down Expand Up @@ -207,13 +208,13 @@ public void onSwitchClick(final DevicesInfo clickedSwitch, boolean checked, Domo
mDomoticz.setAction(idx, jsonUrl, jsonAction, 0, new setCommandReceiver() {
@Override
public void onReceiveResult(String result) {
Toast.makeText(context, "Switch toggled: " + clickedSwitch.getName(), Toast.LENGTH_SHORT).show();
Toast.makeText(context, context.getString(R.string.switch_toggled)+ ": " + clickedSwitch.getName(), Toast.LENGTH_SHORT).show();
updateWidget(context);
}

@Override
public void onError(Exception error) {
Toast.makeText(context, "Failed to toggle switch." + widgetID, Toast.LENGTH_SHORT).show();
Toast.makeText(context, context.getString(R.string.failed_toggeling_switch), Toast.LENGTH_SHORT).show();
}
});
}
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings_widgets.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@
<string name="pick_switch_title">Pick a switch</string>
<string name="choose_switch">Choose Switch</string>
<string name="failed_to_get_switches">Failed to get switches</string>
<string name="failed_toggeling_switch">Failed to toggling switch</string>
<string name="switch_toggled">"Switch toggled: "</string>
</resources>

0 comments on commit 7fee089

Please sign in to comment.