Skip to content
This repository was archived by the owner on Jun 8, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 21 additions & 25 deletions app/src/main/java/info/papdt/blackblub/ui/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,8 @@ private void initSchedulerRow() {
mSchedulerRow = findViewById(R.id.scheduler_row);
mSchedulerIcon = findViewById(R.id.scheduler_icon);
mSchedulerStatus = findViewById(R.id.tv_scheduler_status);
Button settingsButton = findViewById(R.id.btn_scheduler_settings);

settingsButton.setOnClickListener(v -> {
mSchedulerRow.setOnClickListener(v -> {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
PowerManager pm = getSystemService(PowerManager.class);
if (pm != null && !pm.isIgnoringBatteryOptimizations(getPackageName())) {
Expand All @@ -245,7 +244,6 @@ private void initSchedulerRow() {
}
showSchedulerDialog();
});
mSchedulerRow.setOnClickListener(v -> settingsButton.performClick());

updateSchedulerRow();
}
Expand Down Expand Up @@ -303,29 +301,27 @@ private void updateSchedulerRow() {

private void initAdvancedModeRow() {
mAdvancedModeRow = findViewById(R.id.advanced_mode_row);
mAdvancedModeText = findViewById(R.id.advanced_mode_text);
ImageButton settingsButton = findViewById(R.id.btn_advanced_mode_settings);
mAdvancedModeText = findViewById(R.id.tv_mode_status);

mAdvancedModeRow.setOnClickListener(v -> showAdvancedModeDialog());

settingsButton.setOnClickListener(v -> showAdvancedModeDialog());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
settingsButton.setImageResource(R.drawable.ic_help_outline_black_24dp);
settingsButton.setOnClickListener(v -> {
// Show explanation
// Show explanation
mAdvancedModeRow.setOnClickListener(o ->
new AlertDialog.Builder(this)
.setTitle(R.string.mode_android_oreo_explanation_dialog_title)
.setMessage(R.string.mode_android_oreo_explanation_dialog_message)
.setNeutralButton(R.string.mode_android_oreo_explanation_read_more,
(d, w) -> startActivity(
new Intent(Intent.ACTION_VIEW, Uri.parse(
getString(
R.string.mode_android_oreo_explanation_url)
)))
)
.setPositiveButton(android.R.string.ok, (d, w) -> {})
.show();
});
.setTitle(R.string.mode_android_oreo_explanation_dialog_title)
.setMessage(R.string.mode_android_oreo_explanation_dialog_message)
.setNeutralButton(R.string.mode_android_oreo_explanation_read_more,
(d, w) -> startActivity(
new Intent(Intent.ACTION_VIEW, Uri.parse(
getString(
R.string.mode_android_oreo_explanation_url)
)))
)
.setPositiveButton(android.R.string.ok, (d, w) -> {})
.show()
);
}
mAdvancedModeRow.setOnClickListener(v -> settingsButton.performClick());

updateAdvancedModeRow();
}
Expand Down Expand Up @@ -382,9 +378,9 @@ private void showAdvancedModeDialog() {
mSettings.setAdvancedMode(adapter.getItem(which).getModeId());
updateAdvancedModeRow();
// Restart service
mToggle.performClick();
mToggle.postDelayed(() -> mToggle.performClick(), 800);
dialog.dismiss();
mToggle.performClick();
mToggle.postDelayed(() -> mToggle.performClick(), 800);
dialog.dismiss();
})
.setNegativeButton(android.R.string.cancel, null)
.show();
Expand Down
35 changes: 19 additions & 16 deletions app/src/main/res/layout/include_advanced_mode_row.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
android:paddingEnd="16dp"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:gravity="center_vertical"
android:clickable="true"
android:focusable="true"
android:background="?android:attr/selectableItemBackground"
Expand All @@ -23,24 +22,28 @@
android:src="@drawable/ic_developer_board_black_24dp"
android:tint="?attr/icon_tint"/>

<TextView
android:id="@+id/advanced_mode_text"
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:text="@string/mode_text_normal"
android:textAppearance="@android:style/TextAppearance.Material.Body2"/>
android:layout_weight="1"
android:orientation="vertical">

<ImageButton
android:id="@+id/btn_advanced_mode_settings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:padding="4dp"
android:src="@drawable/ic_settings_black_24dp"
android:tint="?attr/icon_tint"
android:background="?android:attr/selectableItemBackgroundBorderless"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:layout_marginBottom="4dp"
android:text="@string/mode_title"
android:textAppearance="@android:style/TextAppearance.Material.Body2" />

<TextView
android:id="@+id/tv_mode_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@android:style/TextAppearance.Material.Body1"
tools:text="Normal" />

</LinearLayout>

</LinearLayout>
26 changes: 13 additions & 13 deletions app/src/main/res/layout/include_more_settings_row.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="horizontal"
android:id="@+id/more_settings_row"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:paddingTop="16dp"
android:paddingEnd="16dp"
android:paddingBottom="16dp"
android:gravity="center_vertical"
android:clickable="true"
android:focusable="true"
android:background="?android:attr/selectableItemBackground"
tools:background="?attr/card_background_color">

<ImageView
Expand All @@ -21,26 +21,26 @@
android:layout_height="wrap_content"
android:importantForAccessibility="no"
android:src="@drawable/ic_settings_applications_black_24dp"
android:tint="?attr/icon_tint"/>
android:tint="?attr/icon_tint" />

<TextView
android:id="@+id/more_settings_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_weight="1"
android:text="@string/more_settings"
android:textAppearance="@android:style/TextAppearance.Material.Body2"/>
android:textAppearance="@android:style/TextAppearance.Material.Body2" />

<ImageButton
android:id="@+id/btn_more_settings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:padding="4dp"
android:src="@drawable/ic_chevron_right_black_24dp"
android:tint="?attr/icon_tint"
android:background="?android:attr/selectableItemBackgroundBorderless"/>
android:tint="?attr/icon_tint" />

</LinearLayout>
33 changes: 12 additions & 21 deletions app/src/main/res/layout/include_scheduler_row.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="horizontal"
android:id="@+id/scheduler_row"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:orientation="horizontal"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:paddingTop="16dp"
android:paddingEnd="16dp"
android:paddingBottom="8dp"
android:clickable="true"
android:focusable="true"
android:background="?android:attr/selectableItemBackground"
tools:background="?attr/card_background_color">

<ImageView
Expand All @@ -20,13 +20,13 @@
android:layout_height="wrap_content"
android:importantForAccessibility="no"
android:src="@drawable/ic_alarm_off_black_24dp"
android:tint="?attr/icon_tint"/>
android:tint="?attr/icon_tint" />

<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_weight="1"
android:orientation="vertical">

<TextView
Expand All @@ -35,24 +35,15 @@
android:layout_marginTop="2dp"
android:layout_marginBottom="4dp"
android:text="@string/scheduler_title"
android:textAppearance="@android:style/TextAppearance.Material.Body2"/>
android:textAppearance="@android:style/TextAppearance.Material.Body2" />

<TextView
android:id="@+id/tv_scheduler_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@android:style/TextAppearance.Material.Body1"
android:layout_marginBottom="8dp"
tools:text="OFF"/>

<Button
android:id="@+id/btn_scheduler_settings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/action_settings"
android:layout_gravity="end"
android:textColor="?attr/icon_tint"
style="@android:style/Widget.Material.Button.Borderless.Small"/>
android:textAppearance="@android:style/TextAppearance.Material.Body1"
tools:text="OFF" />

</LinearLayout>

Expand Down
18 changes: 9 additions & 9 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@
<string name="yellow_filter_explanation">Slide to the right to make the overlay yellow instead of grey</string>

<!-- Scheduler Row -->
<string name="scheduler_status_on_show_enable_time">Automatically enable at %s.</string>
<string name="scheduler_status_on_show_disable_time">It will be end at %s.</string>
<string name="scheduler_status_on_show_enable_time">Dimming will be automatically enabled at %s.</string>
<string name="scheduler_status_on_show_disable_time">Dimming will end at %s.</string>
<string name="scheduler_status_off">OFF</string>
<string name="action_settings">Settings</string>

<!-- Dark theme Row -->
<string name="action_dark_theme">Dark theme</string>
<string name="dark_theme_summary">Switch on to make Night Screen dark</string>

<!-- Advanced Row -->
<string name="mode_title">Dimming mode</string>
<string name="dialog_choose_mode">Choose mode</string>

<string name="mode_text_no_permission">No permission mode</string>
<string name="mode_text_normal">Normal mode</string>
<string name="mode_text_overlay_all">System overlay mode</string>
<string name="mode_text_no_permission">Permissionless</string>
<string name="mode_text_normal">Normal</string>
<string name="mode_text_overlay_all">System overlay</string>

<string name="mode_desc_no_permission">No permission is needed. However, the lockscreen, status bar and navigation bar are not dimmed. Note that this doesn\'t work in Android 7.0.</string>
<string name="mode_desc_no_permission">No permission is needed. However, the lock screen, status bar and navigation bar are not dimmed. Note that this doesn\'t work in Android 7.0.</string>
<string name="mode_desc_normal">Recommended mode. It is stable, although it cannot dim the navigation bar and it prevents users from clicking \"Install\" or \"Allow\" in permission dialogs.</string>
<string name="mode_desc_overlay_all">Both the status bar and the navigation bar are dimmed. However, the screen may flash in some apps.</string>

Expand Down Expand Up @@ -76,8 +76,8 @@
<string name="notification_action_turn_off">Turn off</string>
<string name="notification_action_turn_on">Turn on</string>

<!-- Auto Mode -->
<string name="scheduler_title">Auto mode</string>
<!-- Auto Mode/scheduled dimming -->
<string name="scheduler_title">Scheduled dimming</string>

<string name="dialog_ignore_battery_opt_title">Note</string>
<string name="dialog_ignore_battery_opt_msg">Due to restrictions on apps introduced in Android 6.0, we may not be able to automatically (de-)activate Night Screen on time. \n\nA possible solution is to tell Android to ignore battery optimizations for Night Screen. To do so, tap \"Go to settings\" and confirm the dialog that follows.</string>
Expand Down