diff --git a/app/src/main/java/app/fedilab/android/activities/BaseMainActivity.java b/app/src/main/java/app/fedilab/android/activities/BaseMainActivity.java index 2f0fa66d6..b447f326e 100644 --- a/app/src/main/java/app/fedilab/android/activities/BaseMainActivity.java +++ b/app/src/main/java/app/fedilab/android/activities/BaseMainActivity.java @@ -1149,7 +1149,6 @@ public abstract class BaseMainActivity extends BaseActivity //final SwitchCompat set_push_hometimeline = dialogView.findViewById(R.id.set_push_hometimeline); final SwitchCompat set_push_notification = dialogView.findViewById(R.id.set_push_notification); - boolean notif_hometimeline = sharedpreferences.getBoolean(Helper.SET_NOTIF_HOMETIMELINE, false); boolean notif_follow = sharedpreferences.getBoolean(Helper.SET_NOTIF_FOLLOW, true); boolean notif_add = sharedpreferences.getBoolean(Helper.SET_NOTIF_ADD, true); boolean notif_ask = sharedpreferences.getBoolean(Helper.SET_NOTIF_ASK, true); @@ -1170,7 +1169,6 @@ public abstract class BaseMainActivity extends BaseActivity editor.putBoolean(Helper.SET_NOTIF_MENTION, set_push_notification.isChecked()); editor.putBoolean(Helper.SET_NOTIF_SHARE, set_push_notification.isChecked()); editor.putBoolean(Helper.SET_NOTIF_POLL, set_push_notification.isChecked()); - // editor.putBoolean(Helper.SET_NOTIF_HOMETIMELINE, set_push_hometimeline.isChecked()); editor.putBoolean(Helper.SET_POPUP_PUSH, true); editor.apply(); /*if( set_push_notification.isChecked() ){ diff --git a/app/src/main/java/app/fedilab/android/activities/SettingsActivity.java b/app/src/main/java/app/fedilab/android/activities/SettingsActivity.java index 11b2ca17a..da24c4f98 100644 --- a/app/src/main/java/app/fedilab/android/activities/SettingsActivity.java +++ b/app/src/main/java/app/fedilab/android/activities/SettingsActivity.java @@ -170,23 +170,27 @@ public class SettingsActivity extends BaseActivity implements ViewAnimator.ViewA } private void createMenuList() { - SlideMenuItem menuItem0 = new SlideMenuItem(ContentSettingsFragment.type.CLOSE, R.drawable.ic_close); - list.add(menuItem0); - SlideMenuItem menuItem1 = new SlideMenuItem(ContentSettingsFragment.type.TIMELINES, R.drawable.ic_timeline_menu_s); - list.add(menuItem1); - if( MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA){ - SlideMenuItem menuItem2 = new SlideMenuItem(ContentSettingsFragment.type.ADMIN, R.drawable.ic_security_admin_menu); - list.add(menuItem2); - } - SlideMenuItem menuItem3 = new SlideMenuItem(ContentSettingsFragment.type.NOTIFICATIONS, R.drawable.ic_notifications_menu); - list.add(menuItem3); - SlideMenuItem menuItem4 = new SlideMenuItem(ContentSettingsFragment.type.INTERFACE, R.drawable.ic_tablet_menu); - list.add(menuItem4); - SlideMenuItem menuItem5 = new SlideMenuItem(ContentSettingsFragment.type.COMPOSE, R.drawable.ic_edit_black_menu); - list.add(menuItem5); - SlideMenuItem menuItem6 = new SlideMenuItem(ContentSettingsFragment.type.HIDDEN, R.drawable.ic_visibility_off_menu); - list.add(menuItem6); + + SlideMenuItem menuItemClose = new SlideMenuItem(ContentSettingsFragment.type.CLOSE, R.drawable.ic_close); + SlideMenuItem menuItemTimeline = new SlideMenuItem(ContentSettingsFragment.type.TIMELINES, R.drawable.ic_timeline_menu_s); + SlideMenuItem menuItemNotification = new SlideMenuItem(ContentSettingsFragment.type.NOTIFICATIONS, R.drawable.ic_notifications_menu); + SlideMenuItem menuItemAdmin = new SlideMenuItem(ContentSettingsFragment.type.ADMIN, R.drawable.ic_security_admin_menu); + SlideMenuItem menuItemInterface = new SlideMenuItem(ContentSettingsFragment.type.INTERFACE, R.drawable.ic_tablet_menu); + SlideMenuItem menuItemEdit = new SlideMenuItem(ContentSettingsFragment.type.COMPOSE, R.drawable.ic_edit_black_menu); + SlideMenuItem menuItemHidden = new SlideMenuItem(ContentSettingsFragment.type.HIDDEN, R.drawable.ic_visibility_off_menu); SlideMenuItem menuItem7 = new SlideMenuItem(ContentSettingsFragment.type.ALL, R.drawable.ic_all_inclusive_menu); + SlideMenuItem menuItemBattery = new SlideMenuItem(ContentSettingsFragment.type.BATTERY, R.drawable.ic_battery_alert_menu); + + list.add(menuItemClose); + list.add(menuItemTimeline); + list.add(menuItemNotification); + list.add(menuItemInterface); + list.add(menuItemBattery); + list.add(menuItemEdit); + if( MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA){ + list.add(menuItemAdmin); + } + list.add(menuItemHidden); list.add(menuItem7); } diff --git a/app/src/main/java/app/fedilab/android/fragments/ContentSettingsFragment.java b/app/src/main/java/app/fedilab/android/fragments/ContentSettingsFragment.java index cd9531335..6bc4cc999 100644 --- a/app/src/main/java/app/fedilab/android/fragments/ContentSettingsFragment.java +++ b/app/src/main/java/app/fedilab/android/fragments/ContentSettingsFragment.java @@ -89,6 +89,7 @@ import static android.app.Activity.RESULT_OK; import static android.content.Context.MODE_PRIVATE; import static app.fedilab.android.fragments.ContentSettingsFragment.type.ADMIN; import static app.fedilab.android.fragments.ContentSettingsFragment.type.ALL; +import static app.fedilab.android.fragments.ContentSettingsFragment.type.BATTERY; import static app.fedilab.android.fragments.ContentSettingsFragment.type.COMPOSE; import static app.fedilab.android.fragments.ContentSettingsFragment.type.HIDDEN; import static app.fedilab.android.fragments.ContentSettingsFragment.type.INTERFACE; @@ -112,6 +113,7 @@ public class ContentSettingsFragment extends Fragment implements ScreenShotable INTERFACE, COMPOSE, HIDDEN, + BATTERY, ALL } @@ -232,6 +234,7 @@ public class ContentSettingsFragment extends Fragment implements ScreenShotable LinearLayout settings_compose = rootView.findViewById(R.id.settings_compose); LinearLayout settings_hidden = rootView.findViewById(R.id.settings_hidden); LinearLayout settings_to_do = rootView.findViewById(R.id.settings_to_do); + LinearLayout settings_battery = rootView.findViewById(R.id.settings_battery); if(type == null || type.equals(TIMELINES)){ settings_timeline.setVisibility(View.VISIBLE); @@ -241,6 +244,8 @@ public class ContentSettingsFragment extends Fragment implements ScreenShotable settings_admin.setVisibility(View.VISIBLE); }else if(type == INTERFACE){ settings_interface.setVisibility(View.VISIBLE); + }else if(type == BATTERY){ + settings_battery.setVisibility(View.VISIBLE); }else if(type == COMPOSE){ settings_compose.setVisibility(View.VISIBLE); }else if( type == HIDDEN){ @@ -281,48 +286,7 @@ public class ContentSettingsFragment extends Fragment implements ScreenShotable count4 = 0; count5 = 0; - final Spinner battery_layout_spinner = rootView.findViewById(R.id.battery_layout_spinner); - ArrayAdapter adapterBattery = ArrayAdapter.createFromResource(getContext(), - R.array.battery_profiles, android.R.layout.simple_spinner_item); - battery_layout_spinner.setAdapter(adapterBattery); - int positionSpinner = sharedpreferences.getInt(Helper.SET_BATTERY_PROFILE, Helper.BATTERY_PROFILE_NORMAL) -1; - battery_layout_spinner.setSelection(positionSpinner); - battery_layout_spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { - @Override - public void onItemSelected(AdapterView parent, View view, int position, long id) { - if( count2 > 0){ - SharedPreferences.Editor editor = sharedpreferences.edit(); - switch (position){ - case 0: - editor.putInt(Helper.SET_BATTERY_PROFILE, Helper.BATTERY_PROFILE_NORMAL); - editor.apply(); - break; - case 1: - editor.putInt(Helper.SET_BATTERY_PROFILE, Helper.BATTERY_PROFILE_MEDIUM); - editor.apply(); - break; - case 2: - editor.putInt(Helper.SET_BATTERY_PROFILE, Helper.BATTERY_PROFILE_LOW); - editor.apply(); - break; - } - Helper.changeBatteryProfile(context); - if( position < 2 ){ - try { - ((MainActivity) context).startSreaming(); - }catch (Exception ignored){ignored.printStackTrace();} - }else{ - context.sendBroadcast(new Intent("StopLiveNotificationService")); - } - }else { - count2++; - } - } - @Override - public void onNothingSelected(AdapterView parent) { - } - }); TagsEditText set_featured_tags = rootView.findViewById(R.id.set_featured_tags); if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON){ @@ -671,24 +635,7 @@ public class ContentSettingsFragment extends Fragment implements ScreenShotable } }); - boolean old_direct_timeline = sharedpreferences.getBoolean(Helper.SET_OLD_DIRECT_TIMELINE, false); - final CheckBox set_old_direct_timeline = rootView.findViewById(R.id.set_old_direct_timeline); - set_old_direct_timeline.setChecked(old_direct_timeline); - set_old_direct_timeline.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - SharedPreferences.Editor editor = sharedpreferences.edit(); - editor.putBoolean(Helper.SET_OLD_DIRECT_TIMELINE, set_old_direct_timeline.isChecked()); - editor.apply(); - if( getActivity() != null) - getActivity().recreate(); - Intent intent = new Intent(context, MainActivity.class); - if(getActivity() != null) - getActivity().finish(); - startActivity(intent); - } - }); boolean hide_delete_notification_on_tab = sharedpreferences.getBoolean(Helper.SET_HIDE_DELETE_BUTTON_ON_TAB, false); final CheckBox set_hide_delete_notification_on_tab = rootView.findViewById(R.id.set_hide_delete_notification_on_tab); @@ -1505,7 +1452,6 @@ public class ContentSettingsFragment extends Fragment implements ScreenShotable boolean notif_wifi = sharedpreferences.getBoolean(Helper.SET_WIFI_ONLY, false); boolean notif_silent = sharedpreferences.getBoolean(Helper.SET_NOTIF_SILENT, false); - boolean notif_hometimeline = sharedpreferences.getBoolean(Helper.SET_NOTIF_HOMETIMELINE, false); final String time_from = sharedpreferences.getString(Helper.SET_TIME_FROM, "07:00"); final String time_to = sharedpreferences.getString(Helper.SET_TIME_TO, "22:00"); @@ -1518,7 +1464,6 @@ public class ContentSettingsFragment extends Fragment implements ScreenShotable final CheckBox set_notif_follow_share = rootView.findViewById(R.id.set_notif_follow_share); final CheckBox set_notif_follow_poll = rootView.findViewById(R.id.set_notif_follow_poll); - final CheckBox set_notif_hometimeline = rootView.findViewById(R.id.set_notif_hometimeline); final SwitchCompat switchCompatWIFI = rootView.findViewById(R.id.set_wifi_only); final SwitchCompat switchCompatSilent = rootView.findViewById(R.id.set_silence); @@ -1741,19 +1686,12 @@ public class ContentSettingsFragment extends Fragment implements ScreenShotable set_notif_follow_mention.setChecked(notif_mention); set_notif_follow_share.setChecked(notif_share); set_notif_follow_poll.setChecked(notif_poll); - set_notif_hometimeline.setChecked(notif_hometimeline); + switchCompatWIFI.setChecked(notif_wifi); switchCompatSilent.setChecked(notif_silent); - set_notif_hometimeline.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - SharedPreferences.Editor editor = sharedpreferences.edit(); - editor.putBoolean(Helper.SET_NOTIF_HOMETIMELINE, set_notif_hometimeline.isChecked()); - editor.apply(); - } - }); + set_notif_follow.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { diff --git a/app/src/main/java/app/fedilab/android/fragments/DisplayStatusFragment.java b/app/src/main/java/app/fedilab/android/fragments/DisplayStatusFragment.java index 6fd90c041..bb58de374 100644 --- a/app/src/main/java/app/fedilab/android/fragments/DisplayStatusFragment.java +++ b/app/src/main/java/app/fedilab/android/fragments/DisplayStatusFragment.java @@ -630,7 +630,6 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn public void onResume(){ super.onResume(); boolean liveNotifications = sharedpreferences.getBoolean(Helper.SET_LIVE_NOTIFICATIONS, true); - int batteryProfile = sharedpreferences.getInt(Helper.SET_BATTERY_PROFILE, Helper.BATTERY_PROFILE_NORMAL); if (type == RetrieveFeedsAsyncTask.Type.HOME){ if( getUserVisibleHint() ){ statusListAdapter.updateMuted(mutedAccount); @@ -643,7 +642,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn SharedPreferences.Editor editor = sharedpreferences.edit(); editor.putBoolean(Helper.SHOULD_CONTINUE_STREAMING_FEDERATED + userId + instance, true); editor.apply(); - if(liveNotifications && batteryProfile == Helper.BATTERY_PROFILE_NORMAL) { + if(liveNotifications) { streamingFederatedIntent = new Intent(context, StreamingFederatedTimelineService.class); try { context.startService(streamingFederatedIntent); @@ -658,7 +657,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn SharedPreferences.Editor editor = sharedpreferences.edit(); editor.putBoolean(Helper.SHOULD_CONTINUE_STREAMING_LOCAL + userId + instance, true); editor.apply(); - if( liveNotifications && batteryProfile == Helper.BATTERY_PROFILE_NORMAL) { + if( liveNotifications ) { streamingLocalIntent = new Intent(context, StreamingLocalTimelineService.class); try { context.startService(streamingLocalIntent); @@ -731,7 +730,6 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn if( context == null) return; boolean liveNotifications = sharedpreferences.getBoolean(Helper.SET_LIVE_NOTIFICATIONS, true); - int batteryProfile = sharedpreferences.getInt(Helper.SET_BATTERY_PROFILE, Helper.BATTERY_PROFILE_NORMAL); //Store last toot id for home timeline to avoid to notify for those that have been already seen if (type == RetrieveFeedsAsyncTask.Type.HOME ) { if (visible) { @@ -744,7 +742,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn SharedPreferences.Editor editor = sharedpreferences.edit(); editor.putBoolean(Helper.SHOULD_CONTINUE_STREAMING_FEDERATED + userId + instance, true); editor.apply(); - if(liveNotifications && batteryProfile == Helper.BATTERY_PROFILE_NORMAL) { + if(liveNotifications ) { streamingFederatedIntent = new Intent(context, StreamingFederatedTimelineService.class); try { context.startService(streamingFederatedIntent); @@ -765,7 +763,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn SharedPreferences.Editor editor = sharedpreferences.edit(); editor.putBoolean(Helper.SHOULD_CONTINUE_STREAMING_LOCAL + userId + instance, true); editor.apply(); - if( liveNotifications && batteryProfile == Helper.BATTERY_PROFILE_NORMAL) { + if( liveNotifications ) { streamingLocalIntent = new Intent(context, StreamingLocalTimelineService.class); try { context.startService(streamingLocalIntent); diff --git a/app/src/main/java/app/fedilab/android/helper/Helper.java b/app/src/main/java/app/fedilab/android/helper/Helper.java index 5869f53a4..73a0ce99f 100644 --- a/app/src/main/java/app/fedilab/android/helper/Helper.java +++ b/app/src/main/java/app/fedilab/android/helper/Helper.java @@ -334,8 +334,6 @@ public class Helper { public static final String SET_DISPLAY_EMOJI = "set_display_emoji"; public static final String SET_DISPLAY_CARD = "set_display_card"; public static final String SET_DISPLAY_VIDEO_PREVIEWS= "set_display_video_previews"; - public static final String SET_OLD_DIRECT_TIMELINE = "sset_old_direct_timeline"; - public static final String SET_BATTERY_PROFILE = "set_battery_profile"; public static final String SET_DEFAULT_LOCALE_NEW = "set_default_locale_new"; public static final String SET_NOTIFICATION_ACTION = "set_notification_action"; public static final String SET_DISPLAY_CONTENT_AFTER_FM = "set_display_content_after_fm"; @@ -367,9 +365,6 @@ public class Helper { public static final int VIDEO_MODE_WEBVIEW = 1; public static final int VIDEO_MODE_DIRECT = 2; - public static final int BATTERY_PROFILE_NORMAL = 1; - public static final int BATTERY_PROFILE_MEDIUM = 2; - public static final int BATTERY_PROFILE_LOW = 3; public static final int THEME_LIGHT = 1; public static final int THEME_DARK = 2; @@ -404,7 +399,6 @@ public class Helper { public static final String SET_NOTIF_VALIDATION = "set_share_validation"; public static final String SET_NOTIF_VALIDATION_FAV = "set_share_validation_fav"; public static final String SET_WIFI_ONLY = "set_wifi_only"; - public static final String SET_NOTIF_HOMETIMELINE = "set_notif_hometimeline"; public static final String SET_NOTIF_SILENT = "set_notif_silent"; public static final String SET_EXPAND_CW = "set_expand_cw"; public static final String SET_EXPAND_MEDIA = "set_expand_media"; @@ -3615,29 +3609,6 @@ public class Helper { } } - public static void changeBatteryProfile(Context context){ - SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); - int batteryProfile = sharedpreferences.getInt(Helper.SET_BATTERY_PROFILE, Helper.BATTERY_PROFILE_NORMAL); - SharedPreferences.Editor editor = sharedpreferences.edit(); - switch (batteryProfile){ - case BATTERY_PROFILE_NORMAL: - editor.putBoolean(Helper.SET_LIVE_NOTIFICATIONS, true); - editor.putBoolean(Helper.SET_KEEP_BACKGROUND_PROCESS, true); - editor.apply(); - break; - case BATTERY_PROFILE_MEDIUM: - editor.putBoolean(Helper.SET_LIVE_NOTIFICATIONS, true); - editor.putBoolean(Helper.SET_KEEP_BACKGROUND_PROCESS, false); - editor.apply(); - break; - case BATTERY_PROFILE_LOW: - editor.putBoolean(Helper.SET_LIVE_NOTIFICATIONS, false); - editor.putBoolean(Helper.SET_KEEP_BACKGROUND_PROCESS, false); - editor.apply(); - break; - - } - } public static String[] getLocales(Context context){ String[] locale = new String[20]; diff --git a/app/src/main/res/drawable/ic_battery_alert_menu.xml b/app/src/main/res/drawable/ic_battery_alert_menu.xml new file mode 100644 index 000000000..7326767f5 --- /dev/null +++ b/app/src/main/res/drawable/ic_battery_alert_menu.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/layout/fragment_settings_reveal.xml b/app/src/main/res/layout/fragment_settings_reveal.xml index 71d8ac8d6..62a918a5d 100644 --- a/app/src/main/res/layout/fragment_settings_reveal.xml +++ b/app/src/main/res/layout/fragment_settings_reveal.xml @@ -39,61 +39,119 @@ android:layout_height="match_parent" android:visibility="gone" android:orientation="vertical"> + + + + + + + + + + + + + + + + + + + + - - + android:orientation="horizontal"> + + + + + + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - @@ -887,15 +1018,7 @@ android:orientation="vertical"> - - + - Normal battery drain - Medium battery drain - Low battery drain - - Tabs Menu @@ -687,7 +681,6 @@ Information Display previews in all toots New UX/UI designer - Use the direct timeline prior to Mastodon 2.6 Display video previews Gitlab Support Bug Report @@ -1086,6 +1079,15 @@ Voice message Enable quick reply The account you are replying might not see your message! + If disabled, the app will always load last statuses + If disabled, sensitive media will be hidden with a button + Store media in full size with a long press on previews + Add an ellipse button at the top right for listing all tags/instances/lists + Display an item in the main menu for a quick access to the timeline targeting #Fedilab tag + Keep an open connection to the streaming API for live notifications. + When the app is in background, it will keep a connection to the streaming API. Disable it if you care about your battery. + During the time slot, the app will send notifications. You can reverse (ie: silent) this time slot with the right spinner. + %d vote %d votes