Drain the tofu, and then remove excess moisture by cutting it in half lengthwise and microwaving on high, uncovered, for two minutes. Gently squeeze out and wipe off excess moisture, then throw tofu in the freezer for one or two hours before removing to thaw in the fridge -- this will give the tofu a slightly heavier texture.
Cut tofu into bite-sized pieces. Combine garlic, ginger, red pepper flakes, apple juice, brown sugar, ketchup, apple cider vinegar, water, and soy sauce in a small bowl. Pour half of the mixture over the tofu and reserve the other half for later. Marinade tofu for at least 30 minutes.
Drain any excess marinade from tofu (into your reserve marinade for later). Coat tofu pieces in flour. Heat oil over medium heat in a large frying pan and fry tofu until golden brown on all sides. (Add more oil as needed, but cook it all out before proceeding).
Add reserved marinade to pan, bring to a boil, then lower heat and simmer for 20 minutes. Serve over rice.