Skip to content

Commit a52e96f

Browse files
missed one last deprecated function
1 parent b682ec2 commit a52e96f

File tree

4 files changed

+75
-42
lines changed

4 files changed

+75
-42
lines changed

.idea/workspace.xml

Lines changed: 8 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,61 @@ What is that all about? If an ordinary clock would tell time in the form 10:06:4
77

88
The app, which is meant primarily as a pedagogical tool, offers two different representations of a Chinese Remainder Clock (one analog, and one digital), and works with 12- and 24-hour time. Users can experiment with incrementing or decrementing various units to see how the clock works, or can modify the time directly. Just touch the screen to reveal the various options.
99

10-
## Note: This is effectively abandonware
10+
## Most development on this has stopped
11+
12+
### Why I (mostly) stopped developing this
13+
14+
It became too hard to keep the thing working.
1115

1216
In principle, this code should import directly into AndroidStudio. Just copy the full directory into AndroidStudioProjects and it should be recognized immediately.
1317

14-
In practice, the people who run Google, Gradle, and JetBrains are uninterested or incapable of producing products that don't wreck your build unless you upgrade constantly. I don't mean this as a complaint -- after all, they provide the software for free -- but that doesn't change the fact that **every few months**, some combination of:
18+
In practice, the people who run Google, Gradle, and JetBrains are either uninterested in or incapable of producing an IDE that don't wreck your build unless you upgrade constantly. I don't mean this as a complaint -- after all, they the software is free -- but that doesn't change the fact that **every few months**, some combination of:
1519
* Gradle,
1620
* the Java compiler,
1721
* the Kotlin plugins,
1822
* the Android APIs, and/or
1923
* other things I've forgotten...
2024

21-
...would upgrade to some inconsistent state, forcing me to waste _multiple hours_ just to get the device to build again.
25+
...would "upgrade" to some inconsistent state, forcing me to waste _multiple hours_ just to get the device to build again.
26+
27+
Two examples:
28+
* Antonella recently asked me to send her some pictures of the app in operation. It had been a couple of years since I had touched the code, and I had changed computers at least once. I had to download and start Android Studio. I spent the next 4 hours:
29+
* upgrading Gradle (twice);
30+
* modifying gradle build scripts, gradle properties, and project settings to something Android Studio would actually accept;
31+
* adding `@Deprecated` tags to a few things to silence the compiler;
32+
* removing a development test module that I wasn't using, but Google changed something so that an empty test module preventing me from building the app ;
33+
* adjusting code for things that used to be pointers and no longer are (I can't believe I am writing that); and
34+
* drilling down into an obscure, poorly explained run-time error.
35+
36+
Essentially, what should have been a 10-minute task turned into a 4 1/2-hour exercise in frustration. Most of the problems were entirely the fault of the IDE developers' deciding that things had to change, and not providing an easy upgrade path. Once upon a time, Android Studio made that much easier to figure out; I can remember when they'd tell you not just that there was a problem with your Gradle setup, but they'd tell you which file had to change, what had to change, _and they'd link to it from the error message!_ At the time, that was kind of magical.
37+
38+
* I decided the next day to fix all the deprecation warnings, which required:
39+
* updating the `minSdkVersion`, because I couldn't work out how to make some newer things work otherwise;
40+
* moving to a new color picker gadget, because Google _still_ can't be bothered to provide one of the most common UI tools you'd need, and the new API changed all sorts of types, which means the old `AmbilWarna` one is now unusable;
41+
* removing the old `android.service.dreams.DreamService`, which seemed to difficult to bring up-to-date, especially since Google never really supported it much and I think they've abandoned it anyway;
42+
* changing everything `Activity`- and `Fragment`-related to `androidx`, which merits its own sublist:
43+
* _to Google's credit_,
44+
* most warnings magically went away the moment you finally found which `androidx` API applied and imported it;
45+
* some functions changed their types slightly, so that you no longer have to cast the type and pray everything went well;
46+
* _to Google's discredit_, some pretty fundamental things _did not_ work that way; for example:
47+
* for a `PreferenceFragment`, you had to do things in `onCreate`; with a `PreferenceFragment`, you do things in `onCreatePreferences`;
48+
* `PreferenceActivity` is no longer a thing; it's now another `AppCompatActivity`, and the process of showing them is different from what one could do with a `PreferenceActivity`;
49+
* `Preference` no longer has an `onCreateView` function: you take care of that in the constructor now, and you don't even have to inflate the layout anymore, but merely set the layout resource;
50+
* an `Activity` no longer has a `getFragmentManager` but rather a `getSupportFragmentManager` which, despite the name change, to all appearances does _exactly the same thing_;
51+
* the procedure to obtain strings from the app's resources has changed;
52+
* `Space` formatting was moved out of one library and into another, leading to a confusing compile-time error;
53+
* ...and as far as I can tell, very little of this was documented anywhere aside from StackOverflow questions, as if it would cost Google a great deal of time or effort to state in the `@Deprecated` annotations _where to find the new, appropriate APIs_.
54+
55+
...I also just noticed that I forgot to fix one deprecated item. 😭 Better fix that real quick! (the good news, such as it is, is that that went pretty well... again, [thanks to StackOverflow](https://stackoverflow.com/a/74132434/4526030).)
56+
57+
### Why is this app not on the Google Play Store?
2258

23-
Then there are Google's ever-changing whims on the hurdles a developer has to leap over in order to keep an app listed on the Play Store, which includes the requirement that you log in every now and then, even if you have nothing to do.
59+
It used to be! However, Google imposes a burden that I consider capricious and ever-changing. For example:
60+
* Regularly informing Google on:
61+
* data collection practices;
62+
* credit card / bank account usage;
63+
* ...
64+
*
65+
* That includes the requirement that you log in every now and then, even if you have nothing to do.)
2466

2567
As a hobbyist, I only have so much time and energy, and I wasn't able to keep maintaining it. I greatly regret this, but there's only so much one person can do. I _may_ come back to it from time to time.

app/src/main/java/name/cantanima/chineseremainderclock/Quiz_ABTime.kt

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import android.app.AlertDialog
55
import android.app.Dialog
66
import android.content.DialogInterface
77
import android.os.Bundle
8-
import android.view.Gravity
8+
import android.view.KeyEvent
99
import android.view.View
1010
import android.view.Window
1111
import android.widget.Button
@@ -134,7 +134,16 @@ class ABNumberDialog(
134134
) : Dialog(crc_activity), View.OnClickListener
135135
{
136136

137-
init { setCanceledOnTouchOutside(false) }
137+
init {
138+
setCanceledOnTouchOutside(false)
139+
setOnKeyListener { dialog, keyCode, event ->
140+
if (keyCode == KeyEvent.KEYCODE_BACK && event.action == KeyEvent.ACTION_UP) {
141+
dialog?.cancel()
142+
listener.cancelled()
143+
}
144+
false
145+
}
146+
}
138147

139148
/**
140149
* Similar to [Activity.onCreate], you should initialize your dialog
@@ -159,7 +168,6 @@ class ABNumberDialog(
159168
val toast = Toast.makeText(
160169
context, context.getString(R.string.dial_use), Toast.LENGTH_LONG
161170
)
162-
toast.setGravity(Gravity.TOP, 0, 0)
163171
toast.show()
164172
}
165173
val which_problem = "$complete/$total:"
@@ -187,17 +195,6 @@ class ABNumberDialog(
187195
dismiss()
188196
}
189197

190-
/**
191-
* Called when the dialog has detected the user's press of the back
192-
* key. The default implementation simply cancels the dialog (only if
193-
* it is cancelable), but you can override this to do whatever you want.
194-
*/
195-
@Deprecated("Deprecated in Java")
196-
override fun onBackPressed() {
197-
dismiss()
198-
listener.cancelled()
199-
}
200-
201198
}
202199

203200
class Quiz_abcTime (
@@ -319,7 +316,16 @@ class ABCNumberDialog(
319316
) : Dialog(crc_activity), View.OnClickListener
320317
{
321318

322-
init { setCanceledOnTouchOutside(false) }
319+
init {
320+
setCanceledOnTouchOutside(false)
321+
setOnKeyListener { dialog, keyCode, event ->
322+
if (keyCode == KeyEvent.KEYCODE_BACK && event.action == KeyEvent.ACTION_UP) {
323+
dialog?.cancel()
324+
listener.cancelled()
325+
}
326+
false
327+
}
328+
}
323329

324330
/**
325331
* Similar to [Activity.onCreate], you should initialize your dialog
@@ -341,7 +347,6 @@ class ABCNumberDialog(
341347
val toast = Toast.makeText(
342348
context, context.getString(R.string.dial_use), Toast.LENGTH_LONG
343349
)
344-
toast.setGravity(Gravity.TOP, 0, 0)
345350
toast.show()
346351
}
347352
update_text.text = which_problem
@@ -372,14 +377,4 @@ class ABCNumberDialog(
372377
dismiss()
373378
}
374379

375-
/**
376-
* Called when the dialog has detected the user's press of the back
377-
* key. The default implementation simply cancels the dialog (only if
378-
* it is cancelable), but you can override this to do whatever you want.
379-
*/
380-
@Deprecated("Deprecated in Java")
381-
override fun onBackPressed() {
382-
dismiss()
383-
listener.cancelled()
384-
}
385380
}

app/src/main/java/name/cantanima/chineseremainderclock/Quiz_WhatTimeIsIt.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ public void react_to_answer(int hr, int min) {
124124
+ ( ( new_minute_value < 10 ) ? "0" : "" )
125125
+ new_minute_value;
126126
Toast toast = Toast.makeText(crc_context, message, Toast.LENGTH_LONG);
127-
toast.setGravity(Gravity.TOP, 0, 0);
128127
toast.show();
129128
}
130129

0 commit comments

Comments
 (0)