Time to add some features !
First thing you might like is a bit faster charging by providing constant current at the beginning of the charge cycle.
After that an end of charge indicator is also a nice add-on. (and automatic fan controller)
These features will add a bit more complexity, still part count is kept very low.
For better stability, I added two electrolytics capacitors on input and output.
They are not strictly needed as it is far from a challenging situation for the regulator, but it can't do harm to add them.
Value is not critical, unless you use another regulator in which case you should check the datasheet.
(Low drop regulators often need larger capacitors)
Just make sure the capacitors are rated for a voltage higher than the one in the circuit.
Instead of using a separate LM317 for constant current, it is way better to implement current limiting on the existing regulator.
By doing so, we avoid another 3V drop.
The technique is quite easy, and can be found in some LM317 datasheets, although it doesn't have much explanation.
It is pretty much the same circuit as previously, but R4 has moved on the ground line of the battery.
On previous version, R4 was used to limit current by itself.
In this one, R4 is used as a "current sense" resistor.
It doesn't limit the current alone, but voltage developped on it's pins is used to drive the regulator voltage down - effectively limiting the current output.
It is important to note that it cannot limit current in case of a short circuit or low voltage output.This is because the LM317 will regulate output voltage down to 1.25V when the ADJ pin is connected directly to ground.So below 1.25V, we cannot tell it to decrease the voltage further to decrease the current.(unless we have a negative voltage, but that's another story)
Adjustment is just as the first version, R1, R2, R3 have the same function - set the output voltage.
R4 is however a bit different now.
When current is passing through R4, a voltage appears between it's pins.
When that voltage reaches the threshold of +-0.7V at the base of the transistor, this one starts to conduct and it brings the ADJ pin progressively to ground.
This is just as if we had reduced the value of R2 and R3.
As current continues to increase, the transistors opens more, lowering the regulator voltage up to a point where an equilibrium is found.
The good thing is that now the value of R4 now doesn't vary with the input / output voltage ratio.
Example values for setting current with any cell count :
0.68ohm 1W = 1A
0.47ohm 1W = 1.5A
1.2ohm 500mW = 550mA
Note the lower power rating of the resistor. It is now the voltage regulator that does the regulation job and dissipates the heat.
This again means a heat sink and probably fan is not optional.
If you want to check the constant current value, you cannot simply short the battery leads together.
You must use a resistor in serie to make sure voltage on the + pin doesn't fall below 1.25V.
A 2,2ohm 5W resistor is ok to test currents from 0.5 to 1.5 amps.