Skip to content

Debloat any Android or Google TV over Wi-Fi and get an Apple TV-style home.

Launcher: mirror Hebrew settings and module panels

lionlev213ba5ea01178c
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/LauncherSettingsActivity.java b/launcher/app/src/main/java/com/gathin/tvhome/LauncherSettingsActivity.java
index 914f8866d..e4d1ab463 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/LauncherSettingsActivity.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/LauncherSettingsActivity.java
@@ -10,8 +10,8 @@ import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.provider.Settings;
import android.view.View;
-import android.widget.LinearLayout;
import android.widget.TextView;
+import android.widget.LinearLayout;
import android.widget.Toast;
import java.io.File;
@@ -97,8 +97,10 @@ public final class LauncherSettingsActivity extends Activity {
refresh();
});
}
- // Keep the numeric choices increasing in the Hebrew reading direction. Reorder the
- // actual views so D-pad focus follows their positions without changing the saved values.
+ // Mirror text alignment without globally opting the launcher into RTL. Numeric rows
+ // still need explicit ordering in Android's no-supportsRtl compatibility mode.
+ if (getResources().getBoolean(R.bool.rtl_menu_bar))
+ findViewById(android.R.id.content).setLayoutDirection(View.LAYOUT_DIRECTION_RTL);
if (getResources().getBoolean(R.bool.rtl_app_grid)) {
reverseRow(columnChoices);
reverseRow(rowChoices);
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java b/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
index 13f181e81..2f4c259b1 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
@@ -3374,6 +3374,8 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
if (card == null) return;
View panel = getLayoutInflater().inflate(R.layout.dialog_card_prompt, root, false);
+ boolean rtl = getResources().getBoolean(R.bool.rtl_menu_bar);
+ if (rtl) panel.setLayoutDirection(View.LAYOUT_DIRECTION_RTL);
((TextView) panel.findViewById(R.id.title)).setText(getString(R.string.card_prompt_title, card.appLabel));
((TextView) panel.findViewById(R.id.body)).setText(card.state == Cards.State.RESIGNED
? getString(R.string.card_prompt_resigned, card.appLabel)
@@ -3387,6 +3389,16 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
getString(R.string.card_prompt_identity, card.pkg, Cards.shortDigest(card.digest)));
TextView keep = panel.findViewById(R.id.btnKeep);
TextView show = panel.findViewById(R.id.btnShow);
+ if (rtl) {
+ LinearLayout buttons = (LinearLayout) keep.getParent();
+ buttons.removeAllViews();
+ buttons.addView(show);
+ buttons.addView(keep);
+ keep.setNextFocusLeftId(R.id.btnShow);
+ keep.setNextFocusRightId(R.id.btnKeep);
+ show.setNextFocusLeftId(R.id.btnShow);
+ show.setNextFocusRightId(R.id.btnKeep);
+ }
final Dialog dialog = new Dialog(this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
@@ -3418,8 +3430,10 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
View.OnKeyListener keys = (v, keyCode, event) -> {
if (event.getAction() != KeyEvent.ACTION_DOWN) return false;
if (keyCode == KeyEvent.KEYCODE_DPAD_UP || keyCode == KeyEvent.KEYCODE_DPAD_DOWN) return true;
- if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) return v.getId() == R.id.btnKeep;
- return keyCode == KeyEvent.KEYCODE_DPAD_RIGHT && v.getId() == R.id.btnShow;
+ if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT)
+ return v.getId() == (rtl ? R.id.btnShow : R.id.btnKeep);
+ return keyCode == KeyEvent.KEYCODE_DPAD_RIGHT
+ && v.getId() == (rtl ? R.id.btnKeep : R.id.btnShow);
};
keep.setOnKeyListener(keys);
show.setOnKeyListener(keys);
@@ -3453,6 +3467,8 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
private void showModuleCardsNow() {
View anchor = findViewById(R.id.btnSettings);
View panel = getLayoutInflater().inflate(R.layout.popup_cards, root, false);
+ if (getResources().getBoolean(R.bool.rtl_menu_bar))
+ panel.setLayoutDirection(View.LAYOUT_DIRECTION_RTL);
LinearLayout rows = panel.findViewById(R.id.rows);
final PopupWindow popup = glassPopup(panel, (int) (400 * density));
List<Cards.Card> listed = new ArrayList<>(cards);
@@ -3461,6 +3477,12 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
View row = getLayoutInflater().inflate(R.layout.item_card_row, rows, false);
row.setTag(card.pkg);
((TextView) row.findViewById(R.id.title)).setText(card.label);
+ if (getResources().getBoolean(R.bool.rtl_menu_bar)) {
+ LinearLayout heading = (LinearLayout) row.findViewById(R.id.title).getParent();
+ View status = row.findViewById(R.id.state);
+ heading.removeView(status);
+ heading.addView(status, 0);
+ }
TextView app = row.findViewById(R.id.app);
if (Cards.fold(card.label).equals(Cards.fold(card.appLabel))) app.setVisibility(View.GONE);
else app.setText(getString(R.string.card_app_name, card.appLabel));
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/QuickSettingsActivity.java b/launcher/app/src/main/java/com/gathin/tvhome/QuickSettingsActivity.java
index a13e08450..53783e6fa 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/QuickSettingsActivity.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/QuickSettingsActivity.java
@@ -28,6 +28,16 @@ public final class QuickSettingsActivity extends Activity {
protected void onCreate(Bundle state) {
super.onCreate(state);
setContentView(R.layout.activity_quick_settings);
+ if (getResources().getBoolean(R.bool.rtl_menu_bar)) {
+ View panel = findViewById(R.id.panel);
+ android.widget.FrameLayout.LayoutParams position =
+ (android.widget.FrameLayout.LayoutParams) panel.getLayoutParams();
+ position.gravity = android.view.Gravity.TOP | android.view.Gravity.LEFT;
+ int inset = position.getMarginEnd();
+ position.setMarginEnd(0);
+ position.setMargins(inset, position.topMargin, 0, position.bottomMargin);
+ panel.setLayoutParams(position);
+ }
findViewById(R.id.scrim).setOnClickListener(v -> finish());
LinearLayout rows = findViewById(R.id.rows);
addRow(rows, R.drawable.ic_settings, R.string.tv_settings, 0, SystemSettings.intent(this, Settings.ACTION_SETTINGS));
diff --git a/tests/test_hebrew_resources.py b/tests/test_hebrew_resources.py
index 18a22f397..3106ae512 100644
--- a/tests/test_hebrew_resources.py
+++ b/tests/test_hebrew_resources.py
@@ -21,12 +21,19 @@ class HebrewResourcesTest(unittest.TestCase):
hebrew = {v.attrib["name"]: v for v in ET.parse(RES / "values-iw/strings.xml").getroot()}
placeholders = re.compile(r"%(?:\d+\$)?[-#+ 0,(]*\d*(?:\.\d+)?[a-zA-Z]")
for value in default:
- if value.tag != "string" or value.get("translatable") == "false":
+ if value.tag not in ("string", "plurals") or value.get("translatable") == "false":
continue
name = value.attrib["name"]
with self.subTest(string=name):
self.assertIn(name, hebrew)
- if name in hebrew:
+ if value.tag == "plurals" and name in hebrew:
+ default_other = value.find("item[@quantity='other']")
+ translated_other = hebrew[name].find("item[@quantity='other']")
+ self.assertIsNotNone(translated_other)
+ if translated_other is not None:
+ self.assertEqual(sorted(placeholders.findall(default_other.text or "")),
+ sorted(placeholders.findall(translated_other.text or "")))
+ elif name in hebrew:
self.assertEqual(sorted(placeholders.findall(value.text or "")),
sorted(placeholders.findall(hebrew[name].text or "")))