Skip to content

Commit

Permalink
Fix issues 3, 4, 5, 6
Browse files Browse the repository at this point in the history
  • Loading branch information
rparkins999 committed Jun 22, 2022
1 parent 95021c4 commit 3ec1b3c
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 70 deletions.
4 changes: 2 additions & 2 deletions SecondsClock/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ android {
applicationId "uk.co.yahoo.p1rpp.secondsclock"
minSdk 26
targetSdk 26
versionCode 6
versionName "2.2"
versionCode 7
versionName "2.3"
}
buildTypes {
release {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,16 @@ public abstract class Activity_common extends Activity implements View.OnLongCli

protected static final int CONFIGURE = 0; // m_currentView default value

// View IDs for buttons, to switch on click or long click:
// View IDs for top level menu buttons, to switch on click or long click:
// also used as widget touch preference values, except that
// CONFIGURE_NEW_WIDGET isn't a widget touch preference, and
// CHOOSE_ACTION isn't a button, as we're already doing it if we get here.
// GO_SECONDS_CLOCK isn't a button because we're alread there,
// and CHOOSE_ACTION is both a button in the widget configuration page
// and a possible action when teh widget is touched.
protected static final int LONGPRESSHELP = 9091;
protected static final int GO_SYSTEM_CLOCK = LONGPRESSHELP + 1;
protected static final int CONFIGURE_NEW_WIDGET = GO_SYSTEM_CLOCK + 1;
protected static final int GO_SECONDS_CLOCK = GO_SYSTEM_CLOCK + 1;
protected static final int CONFIGURE_NEW_WIDGET = GO_SECONDS_CLOCK + 1;
protected static final int CONFIGURE_EXISTING_WIDGET =
CONFIGURE_NEW_WIDGET + 1;
protected static final int CONFIGURE_NIGHT_CLOCK =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public void onClick(View v) {
case GO_SYSTEM_CLOCK:
goSystemClock();
break;
// GO_SECONDS_CLOCK isn't a main menu button
case CONFIGURE_NEW_WIDGET:
m_prefs.edit().putInt("Wview", CONFIGURE).commit();
startActivity(new Intent(
Expand All @@ -105,6 +106,12 @@ public void onClick(View v) {
m_prefs.edit().putInt("Wview", CONFIGURE)
.putInt("Wconfiguring", 1).commit();
doToast(R.string.actionoldwidget);
Intent homeIntent= new Intent(Intent.ACTION_MAIN);
homeIntent.addCategory(Intent.CATEGORY_HOME);
homeIntent.setFlags(
Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(homeIntent);
finish();
break;
case CONFIGURE_NIGHT_CLOCK:
Expand All @@ -131,6 +138,7 @@ public boolean onLongClick(View v) {
doToast(R.string.mainactivityhelp); return true;
case GO_SYSTEM_CLOCK:
doToast(R.string.helpgosysclock); return true;
// GO_SECONDS_CLOCK isn't a main menu button
case CONFIGURE_NEW_WIDGET:
doToast(R.string.helpconfignewwidget); return true;
case CONFIGURE_THIS_WIDGET:
Expand Down Expand Up @@ -211,7 +219,8 @@ protected void onStart() {
sendBroadcast(intent);
}
}
// CHOOSE_ACTION or we got launched: onResume will set up our screen.
// CHOOSE_ACTION or GO_SECONDS_CLOCK or we got launched:
// onResume will set up our screen.
}

@SuppressLint("SetTextI18n")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ void updateAppWidget(
if (Objects.requireNonNull(widgetIds).contains(thisWidget)) {
// Get the preferences for this widget.
showTime =
prefs.getInt(key +" showTime", 2); // include seconds
prefs.getInt(key + "showTime", 2); // include seconds
showWeekDay =
prefs.getInt(key + " showWeekDay", 2); // long format
showShortDate = prefs.getInt(key +" showShortDate", 0);
prefs.getInt(key + "showWeekDay", 2); // long format
showShortDate = prefs.getInt(key + "showShortDate", 0);
showMonthDay =
prefs.getInt(key + "showMonthDay", 1);
showMonth =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class WidgetConfigureActivity extends ConfigureActivity
private Button fgButton;
private Button chooseButton;
private CheckBox sysClockCheckBox;
private CheckBox secondsClockCheckBox;
private CheckBox configThisCheckBox;
private CheckBox configNightClockCheckBox;
private CheckBox runNightClockCheckBox;
Expand Down Expand Up @@ -80,7 +81,10 @@ public boolean onLongClick(View v) {
case SETTEXTCOLOUR: doToast(R.string.setfgcolourhelp); return true;
case SETBACKGROUNDCOLOUR: doToast(R.string.setbgcolourhelp); return true;
case GO_SYSTEM_CLOCK:
doToast(R.string.touchrunnightclock);
doToast(R.string.helptouchsysclock);
return true;
case GO_SECONDS_CLOCK:
doToast(R.string.helptouchsecondsclock);
return true;
case CONFIGURE_EXISTING_WIDGET:
doToast(R.string.helpconfigwidget);
Expand All @@ -100,54 +104,37 @@ public boolean onLongClick(View v) {
}
return super.onLongClick(v);
}

private void fixCheckBoxes(int action) {
if (!recursive) {
recursive = true;
sysClockCheckBox.setChecked(action == GO_SYSTEM_CLOCK);
secondsClockCheckBox.setChecked(action == GO_SECONDS_CLOCK);
configThisCheckBox.setChecked(action == CONFIGURE_EXISTING_WIDGET);
configNightClockCheckBox.setChecked(action == CONFIGURE_NIGHT_CLOCK);
runNightClockCheckBox.setChecked(action == GO_NIGHT_CLOCK);
chooseCheckBox.setChecked(action == CHOOSE_ACTION);
recursive = false;
}
}

@SuppressLint("ApplySharedPref")
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
switch (buttonView.getId()) {
case GO_SYSTEM_CLOCK:
configThisCheckBox.setChecked(false);
configNightClockCheckBox.setChecked(false);
runNightClockCheckBox.setChecked(false);
chooseCheckBox.setChecked(false);
m_prefs.edit().putInt(
m_key + "touchaction", GO_SYSTEM_CLOCK).commit();
break;
case CONFIGURE_EXISTING_WIDGET:
sysClockCheckBox.setChecked(false);
configNightClockCheckBox.setChecked(false);
runNightClockCheckBox.setChecked(false);
chooseCheckBox.setChecked(false);
m_prefs.edit().putInt(m_key + "touchaction",
CONFIGURE_EXISTING_WIDGET).commit();
break;
case CONFIGURE_NIGHT_CLOCK:
sysClockCheckBox.setChecked(false);
configThisCheckBox.setChecked(false);
runNightClockCheckBox.setChecked(false);
chooseCheckBox.setChecked(false);
m_prefs.edit().putInt(
m_key + "touchaction", CONFIGURE_NIGHT_CLOCK).commit();
break;
case GO_NIGHT_CLOCK:
sysClockCheckBox.setChecked(false);
configThisCheckBox.setChecked(false);
configNightClockCheckBox.setChecked(false);
chooseCheckBox.setChecked(false);
m_prefs.edit().putInt(
m_key + "touchaction", GO_NIGHT_CLOCK).commit();
break;
case CHOOSE_ACTION:
sysClockCheckBox.setChecked(false);
configThisCheckBox.setChecked(false);
configNightClockCheckBox.setChecked(false);
runNightClockCheckBox.setChecked(false);
m_prefs.edit().putInt(
m_key + "touchaction", CHOOSE_ACTION).commit();
break;
default:
super.onCheckedChanged(buttonView, isChecked);
}
int action = buttonView.getId();
switch (action) {
case GO_SYSTEM_CLOCK:
case GO_SECONDS_CLOCK:
case CONFIGURE_EXISTING_WIDGET:
case CONFIGURE_NIGHT_CLOCK:
case GO_NIGHT_CLOCK:;
case CHOOSE_ACTION:;
fixCheckBoxes(action);
m_prefs.edit().putInt(
m_key + "touchaction", action).commit();
break;
default:
super.onCheckedChanged(buttonView, isChecked);
}
}

Expand Down Expand Up @@ -313,7 +300,6 @@ private void doMainLayout() {
ScrollView lscroll = new ScrollView(this);
lscroll.setScrollbarFadingEnabled(false);
LinearLayout l1 = new LinearLayout(this);
l1.setBackgroundColor(0xFF000000);
if (m_orientation == Configuration.ORIENTATION_LANDSCAPE) {
l1.setOrientation(LinearLayout.HORIZONTAL);
LinearLayout l2 = new LinearLayout(this);
Expand Down Expand Up @@ -404,7 +390,6 @@ protected void doChooserLayout() {
LinearLayout lc = makeChooser();
int pad = (int)(5 * m_density);
LinearLayout l1 = new LinearLayout(this);
l1.setBackgroundColor(0xFF000000);
demobox.addView(demo);
demoboxbox.setLayoutParams(lpMatchWrap);
demoboxbox.setOrientation(LinearLayout.VERTICAL);
Expand Down Expand Up @@ -549,13 +534,13 @@ protected void doActionLayout() {
lbuttons.setOrientation(LinearLayout.VERTICAL);
lbuttons.addView(centredLabel(R.string.actionpage, LONGPRESSHELP));
lbuttons.addView(sysClockCheckBox, lpWrapWrap);
lbuttons.addView(secondsClockCheckBox, lpWrapWrap);
lbuttons.addView(configThisCheckBox, lpWrapWrap);
lbuttons.addView(configNightClockCheckBox, lpWrapWrap);
lbuttons.addView(runNightClockCheckBox, lpWrapWrap);
lbuttons.addView(chooseCheckBox, lpWrapWrap);
LinearLayout l1 = new LinearLayout(this);
// default orientation is HORIZONTAL
l1.setBackgroundColor(0xFF000000);
if (m_orientation == Configuration.ORIENTATION_LANDSCAPE) {
LinearLayout l2 = new LinearLayout(this);
l2.setOrientation(LinearLayout.VERTICAL);
Expand Down Expand Up @@ -690,7 +675,7 @@ public void onCheckedChanged(
showSecondsCheckBox.setVisibility(View.INVISIBLE);
}
}
m_prefs.edit().putInt("WshowTime", showTime).commit();
m_prefs.edit().putInt(m_key + "showTime", showTime).commit();
updateWidget();
updateDemo();
}
Expand All @@ -711,7 +696,7 @@ public void onCheckedChanged(
} else {
showTime = 1;
}
m_prefs.edit().putInt("WshowTime", showTime).commit();
m_prefs.edit().putInt(m_key + "showTime", showTime).commit();
updateWidget();
updateDemo();
}
Expand All @@ -732,40 +717,41 @@ public void onCheckedChanged(
chooseButton = new Button(this);
chooseButton.setId(CHOOSE_ACTION);
chooseButton.setAllCaps(false);
chooseButton.setText(R.string.chooseaction);
chooseButton.setText(R.string.setaction);
chooseButton.setOnClickListener(this);
chooseButton.setOnLongClickListener(this);
int action = m_prefs.getInt(m_key + "touchaction", CHOOSE_ACTION);
sysClockCheckBox = new CheckBox(this);
sysClockCheckBox.setId(GO_SYSTEM_CLOCK);
sysClockCheckBox.setText(getString(R.string.gosysclock));
sysClockCheckBox.setChecked(action == GO_SYSTEM_CLOCK);
sysClockCheckBox.setOnCheckedChangeListener(this);
sysClockCheckBox.setOnLongClickListener(this);
secondsClockCheckBox = new CheckBox(this);
secondsClockCheckBox.setId(GO_SECONDS_CLOCK);
secondsClockCheckBox.setText(getString(R.string.gosecondsclock));
secondsClockCheckBox.setOnCheckedChangeListener(this);
secondsClockCheckBox.setOnLongClickListener(this);
configThisCheckBox = new CheckBox(this);
configThisCheckBox.setId(CONFIGURE_EXISTING_WIDGET);
configThisCheckBox.setText(getString(R.string.configwidget));
configThisCheckBox.setChecked(action == CONFIGURE_EXISTING_WIDGET);
configThisCheckBox.setOnCheckedChangeListener(this);
configThisCheckBox.setOnLongClickListener(this);
configNightClockCheckBox = new CheckBox(this);
configNightClockCheckBox.setId(CONFIGURE_NIGHT_CLOCK);
configNightClockCheckBox.setText(getString(R.string.confignightclock));
configNightClockCheckBox.setChecked(action == CONFIGURE_NIGHT_CLOCK);
configNightClockCheckBox.setOnCheckedChangeListener(this);
configNightClockCheckBox.setOnLongClickListener(this);
runNightClockCheckBox = new CheckBox(this);
runNightClockCheckBox.setId(GO_NIGHT_CLOCK);
runNightClockCheckBox.setText(getString(R.string.runnightclock));
runNightClockCheckBox.setChecked(action == GO_NIGHT_CLOCK);
runNightClockCheckBox.setOnCheckedChangeListener(this);
runNightClockCheckBox.setOnLongClickListener(this);
chooseCheckBox = new CheckBox(this);
chooseCheckBox.setId(CHOOSE_ACTION);
chooseCheckBox.setText(getString(R.string.chooseaction));
chooseCheckBox.setChecked(action == CHOOSE_ACTION);
chooseCheckBox.setOnCheckedChangeListener(this);
chooseCheckBox.setOnLongClickListener(this);
int action = m_prefs.getInt(m_key + "touchaction", CHOOSE_ACTION);
fixCheckBoxes(action);

saturationValue.addTextChangedListener(new TextWatcher() {
@Override
Expand Down
Binary file modified SecondsClock/src/main/res/drawable/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 6 additions & 3 deletions SecondsClock/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
default clock app.</string>
<string name="helptouchsysclock">Check this box to make a touch on the
widget go to the device\'s default clock app.</string>
<string name="gosecondsclock">Go to SecondsClock app</string>
<string name="helptouchsecondsclock">Check this box to make a touch on the
widget go to this app (SecondsClock).</string>
<string name="confignewwidget">Configure new widget</string>
<string name="helpconfignewwidget">Touch this button to set the configuration
for new widgets. To create a new widget, long press in an empty
Expand All @@ -33,7 +36,7 @@
to configure.</string>
<string name="configwidget">Configure this widget</string>
<string name="helpconfigthis">Touch this button to configure the
the widegt that you touched.</string>
widget that you touched.</string>
<string name="helpconfigwidget">Check this box to make a touch on the
widget go to the configuration page to reconfigure it.</string>
<string name="confignightclock">Configure full screen clock</string>
Expand All @@ -46,7 +49,7 @@
the full screen clock.</string>
<string name="touchrunnightclock">Check this box to make a touch on the
widget run the full screen clock.</string>
<string name="chooseaction">Choose action when touched</string>
<string name="chooseaction">Go to action menu when touched</string>
<string name="touchchooseaction">Check this box to make a touch on the
widget go to the top level menu for the app to choose what to
do next.</string>
Expand All @@ -72,7 +75,7 @@
<string name="widgetconfighelp">This page allows you to configure a widget.
If you came here from a particular widget, it reconfigures that:
if you came here from the top level page,
it sets the the configuration for new widgets.
it sets the configuration for new widgets.
You can make multiple widgets with different configurations.
Long press on anything for a longer description of what it does.</string>
<string name="clockconfighelp">This page allows you to configure
Expand Down
1 change: 1 addition & 0 deletions fastlane/metadata/android/en-US/changeLogs/7.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix issues 3, 4, 5, 6

0 comments on commit 3ec1b3c

Please sign in to comment.