mirror of
https://github.com/nextcloud/notes-android.git
synced 2024-11-24 05:46:14 +03:00
#1531 Add option to not keep screen on
Signed-off-by: Stefan Niedermann <info@niedermann.it>
This commit is contained in:
parent
9f88971d53
commit
a06e648d17
6 changed files with 48 additions and 7 deletions
|
@ -1,5 +1,7 @@
|
|||
package it.niedermann.owncloud.notes.edit;
|
||||
|
||||
import static it.niedermann.owncloud.notes.shared.model.ENavigationCategoryType.FAVORITES;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
|
@ -20,26 +22,22 @@ import com.nextcloud.android.sso.helper.SingleAccountHelper;
|
|||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Calendar;
|
||||
import java.util.Objects;
|
||||
|
||||
import it.niedermann.android.sharedpreferences.SharedPreferenceBooleanLiveData;
|
||||
import it.niedermann.owncloud.notes.LockedActivity;
|
||||
import it.niedermann.owncloud.notes.R;
|
||||
import it.niedermann.owncloud.notes.accountpicker.AccountPickerListener;
|
||||
import it.niedermann.owncloud.notes.databinding.ActivityEditBinding;
|
||||
import it.niedermann.owncloud.notes.databinding.ActivityEditBinding;
|
||||
import it.niedermann.owncloud.notes.edit.category.CategoryViewModel;
|
||||
import it.niedermann.owncloud.notes.persistence.entity.Account;
|
||||
import it.niedermann.owncloud.notes.persistence.entity.Note;
|
||||
import it.niedermann.owncloud.notes.shared.model.DBStatus;
|
||||
import it.niedermann.owncloud.notes.shared.model.NavigationCategory;
|
||||
import it.niedermann.owncloud.notes.shared.util.NoteUtil;
|
||||
import it.niedermann.owncloud.notes.shared.util.ShareUtil;
|
||||
|
||||
import static it.niedermann.owncloud.notes.shared.model.ENavigationCategoryType.FAVORITES;
|
||||
|
||||
public class EditNoteActivity extends LockedActivity implements BaseNoteFragment.NoteFragmentListener, AccountPickerListener {
|
||||
|
||||
private static final String TAG = EditNoteActivity.class.getSimpleName();
|
||||
|
@ -72,7 +70,14 @@ public class EditNoteActivity extends LockedActivity implements BaseNoteFragment
|
|||
return;
|
||||
}
|
||||
|
||||
final var preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||
new SharedPreferenceBooleanLiveData(preferences, getString(R.string.pref_key_keep_screen_on), true).observe(this, keepScreenOn -> {
|
||||
if (keepScreenOn) {
|
||||
Toast.makeText(getApplicationContext(), "ADD flag", Toast.LENGTH_SHORT).show();
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
categoryViewModel = new ViewModelProvider(this).get(CategoryViewModel.class);
|
||||
binding = ActivityEditBinding.inflate(getLayoutInflater());
|
||||
|
@ -103,6 +108,7 @@ public class EditNoteActivity extends LockedActivity implements BaseNoteFragment
|
|||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
Toast.makeText(getApplicationContext(), "REMOVE flag", Toast.LENGTH_SHORT).show();
|
||||
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
super.onStop();
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ public class PreferencesFragment extends PreferenceFragmentCompat implements Bra
|
|||
private BrandedSwitchPreference gridViewPref;
|
||||
private BrandedSwitchPreference preventScreenCapturePref;
|
||||
private BrandedSwitchPreference backgroundSyncPref;
|
||||
private BrandedSwitchPreference keepScreenOnPref;
|
||||
|
||||
@Override
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
|
@ -55,6 +56,16 @@ public class PreferencesFragment extends PreferenceFragmentCompat implements Bra
|
|||
Log.e(TAG, "Could not find preference with key: \"" + getString(R.string.pref_key_gridview) + "\"");
|
||||
}
|
||||
|
||||
keepScreenOnPref = findPreference(getString(R.string.pref_key_keep_screen_on));
|
||||
if (keepScreenOnPref != null) {
|
||||
keepScreenOnPref.setOnPreferenceChangeListener((Preference preference, Object newValue) -> {
|
||||
Log.v(TAG, "keepScreenOnPref: " + keepScreenOnPref);
|
||||
return true;
|
||||
});
|
||||
} else {
|
||||
Log.e(TAG, "Could not find preference with key: \"" + getString(R.string.pref_key_gridview) + "\"");
|
||||
}
|
||||
|
||||
preventScreenCapturePref = findPreference(getString(R.string.pref_key_prevent_screen_capture));
|
||||
if (preventScreenCapturePref == null) {
|
||||
Log.e(TAG, "Could not find \"" + getString(R.string.pref_key_prevent_screen_capture) + "\"-preference.");
|
||||
|
@ -125,5 +136,6 @@ public class PreferencesFragment extends PreferenceFragmentCompat implements Bra
|
|||
gridViewPref.applyBrand(mainColor, textColor);
|
||||
preventScreenCapturePref.applyBrand(mainColor, textColor);
|
||||
backgroundSyncPref.applyBrand(mainColor, textColor);
|
||||
keepScreenOnPref.applyBrand(mainColor, textColor);
|
||||
}
|
||||
}
|
||||
|
|
11
app/src/main/res/drawable/ic_baseline_smartphone_24.xml
Normal file
11
app/src/main/res/drawable/ic_baseline_smartphone_24.xml
Normal file
|
@ -0,0 +1,11 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:autoMirrored="true"
|
||||
android:tint="#757575"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#FF757575"
|
||||
android:pathData="M17,1.01L7,1c-1.1,0 -2,0.9 -2,2v18c0,1.1 0.9,2 2,2h10c1.1,0 2,-0.9 2,-2V3c0,-1.1 -0.9,-1.99 -2,-1.99zM17,19H7V5h10v14z" />
|
||||
</vector>
|
|
@ -49,6 +49,9 @@
|
|||
<string name="settings_lock_summary">Device credentials</string>
|
||||
<string name="settings_background_sync">Background synchronization</string>
|
||||
<string name="settings_prevent_screen_capture">Prevent screen capture</string>
|
||||
<string name="settings_gridview">Grid view</string>
|
||||
<string name="settings_keep_screen_on">Keep screen on</string>
|
||||
<string name="settings_keep_screen_on_summary">When viewing or editing a note</string>
|
||||
|
||||
<string name="error_sync">Synchronization failed: %1$s</string>
|
||||
<string name="error_synchronization">Synchronization failed</string>
|
||||
|
@ -108,6 +111,7 @@
|
|||
<string name="pref_key_theme" translatable="false">darkTheme</string>
|
||||
<string name="pref_key_font" translatable="false">font</string>
|
||||
<string name="pref_key_gridview" translatable="false">gridview</string>
|
||||
<string name="pref_key_keep_screen_on" translatable="false">keepScreenOn</string>
|
||||
<string name="pref_key_font_size" translatable="false">fontSize</string>
|
||||
<string name="pref_key_wifi_only" translatable="false">wifiOnly</string>
|
||||
<string name="pref_key_lock" translatable="false">lock</string>
|
||||
|
@ -201,7 +205,6 @@
|
|||
<string name="append_to_note">Append to note</string>
|
||||
<string name="change_note_title">Change note title</string>
|
||||
<string name="menu_edit_title">Edit title</string>
|
||||
<string name="settings_gridview">Grid view</string>
|
||||
<string name="simple_security">Security</string>
|
||||
<string name="appearance_and_behavior">Appearance and behavior</string>
|
||||
<string name="simple_synchronization">Synchronization</string>
|
||||
|
|
|
@ -67,6 +67,14 @@
|
|||
android:layout="@layout/item_pref"
|
||||
android:summary="%s"
|
||||
android:title="@string/settings_note_mode" />
|
||||
|
||||
<it.niedermann.owncloud.notes.branding.BrandedSwitchPreference
|
||||
android:defaultValue="true"
|
||||
android:icon="@drawable/ic_baseline_smartphone_24"
|
||||
android:key="@string/pref_key_keep_screen_on"
|
||||
android:layout="@layout/item_pref"
|
||||
android:summary="@string/settings_keep_screen_on_summary"
|
||||
android:title="@string/settings_keep_screen_on" />
|
||||
</it.niedermann.owncloud.notes.branding.BrandedPreferenceCategory>
|
||||
|
||||
<it.niedermann.owncloud.notes.branding.BrandedPreferenceCategory
|
||||
|
|
1
fastlane/metadata/android/en-US/changelogs/3005001.txt
Normal file
1
fastlane/metadata/android/en-US/changelogs/3005001.txt
Normal file
|
@ -0,0 +1 @@
|
|||
- 📱️ Add option to not keep screen on (#1531)
|
Loading…
Reference in a new issue