Don't let us scare you off. July WILL be warm but you can still have a great time. Just plan on taking things a bit easy.
Most first-timers find that one night in a ryokan is sufficient. Think of it as a destination rather than just lodging. Soak up the relaxation, enjoy the bath and meals. That is why it is often worth hundreds of dollars/euros/pounds for a single night but may not be worth those rates for multiple nights.
If you change the departure to KIX, I think 4 nights Tokyo and 4 nights Kyoto is just about right. You are correct in thinking there is a lot to see and do in Tokyo. There is also a lot to see and do in Kansai, which is why we suggested not shorting your stay there.
To enjoy your visit despite the heat, we often suggest things that will get you out of the heat, at least some of the time. In Tokyo, the Edo-Tokyo museum in Ryogoku is one of my favorites and always seems cool inside. The big sumo stadium is right next door and has an interesting, if tiny, museum attached. The July tournament will be going on in Nagoya in July, so it should be quiet around the Kokugikan in Tokyo. If your dates are between July 12 and July 27, the tournament will be on TV during the late afternoons - 4:00 to 6:00pm and might be something to do while getting out of the heat at your hotel. The broadcast is available in English at most tourist hotels. You mentioned shopping. A big Japanese department store is a destination in itself. A trip to Ginza or Shibuya to visit on of the big ones would be a fun time and air-conditioned. Don't forget to visit the food floor in the basement.
For Tokyo, a day trip to Nikko will get you up in the mountains and out of some of the heat - and is quite beautiful as well. The National Museum in Ueno Park is also climate controlled. For strolling in Asakusa, the Yanaka-Nezu neighborhood or around the Imperial Palace garden, you might think about early mornings. Ginza is nice after the sun has gone down, with all the store displays lit up. If you get lucky, summer is when a lot of local neighborhood matsuri (festivals) are held and might make a nice evening visit. Summer is also when a lot of fireworks displays are fired off over the river. Ask the concierge at your hotel.
In Kyoto, many of the sights you will want to visit are OLD and not air-conditioned. Just pace yourself and go early morning or evening, if possible. Carry coins as there are cold drink vending machines on every corner and staying hydrated will help you to enjoy the visit. The Westin in Kyoto is the old Miyako Hotel. It is nice and located in the shady, park-like eastern area and within short walking distance of some of the nicer attractions. For other areas, I'd splurge on cabs occasionally to get out of the hot buses. In Kyoto, despite the heat, you will probably want to visit some - or most - of the main sites: Sanjusangen-do, Kiyumizu-dera Temple, the Heian Jingu Shrine, Kinkaku-ji (the golden pavillion), Ryoan-ji Temple with the stone garden, Nijo Castle and perhaps the Imperial Palace Park. I don't recommend the Imperial Palace tour unless you have extra time. A day trip to Nara will get you into the hills but not really high enough to beat much of the heat. The main park area in Nara is where the major attractions are located and is shady and relatively cool. Himeji is worth the trip, even though it will be warm. Just go slow and carry cool drinks as you explore the castle.
JR