Finished contacts shortcut in laucher feature

This commit is contained in:
Sylvain Berfini 2019-06-21 17:26:43 +02:00
parent 245452279a
commit 3f7d43aa2a
5 changed files with 24 additions and 4 deletions

View file

@ -13,7 +13,7 @@ Group changes to describe their impact on the project, as follows:
## [Unreleased]
### Added
- Added shortcuts to calls history & chat rooms list
- Added shortcuts to contacts' latest chat rooms
- Improved device's do not disturb policy compliance
- Added sample application to help developpers getting started with our SDK
- Added picture in picture feature if supported instead of video overlay

View file

@ -42,6 +42,12 @@ import org.linphone.utils.LinphoneUtils;
@TargetApi(25)
class ApiTwentyFivePlus {
public static void removeChatShortcuts(Context context) {
ShortcutManager shortcutManager =
(ShortcutManager) context.getSystemService(Context.SHORTCUT_SERVICE);
shortcutManager.removeAllDynamicShortcuts();
}
public static void createChatShortcuts(Context context) {
if (!LinphonePreferences.instance().shortcutsCreationEnabled()) return;

View file

@ -251,6 +251,12 @@ public class Compatibility {
}
}
public static void removeChatShortcuts(Context context) {
if (Version.sdkAboveOrEqual(Version.API25_NOUGAT_71)) {
ApiTwentyFivePlus.removeChatShortcuts(context);
}
}
public static void enterPipMode(Activity activity) {
if (Version.sdkAboveOrEqual(Version.API26_O_80)) {
ApiTwentySixPlus.enterPipMode(activity);

View file

@ -24,6 +24,8 @@ import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.Nullable;
import org.linphone.R;
import org.linphone.compatibility.Compatibility;
import org.linphone.mediastream.Version;
import org.linphone.settings.widget.SettingListenerBase;
import org.linphone.settings.widget.SwitchSetting;
@ -79,10 +81,11 @@ public class ContactSettingsFragment extends SettingsFragment {
mDisplayDetailContact.setVisibility(View.INVISIBLE);
}
if (getResources().getBoolean(R.bool.create_most_recent_chat_rooms_shortcuts)) {
if (Version.sdkAboveOrEqual(Version.API25_NOUGAT_71)
&& getResources().getBoolean(R.bool.create_most_recent_chat_rooms_shortcuts)) {
mCreateShortcuts.setChecked(mPrefs.shortcutsCreationEnabled());
} else {
mCreateShortcuts.setVisibility(View.INVISIBLE);
mCreateShortcuts.setVisibility(View.GONE);
}
}
@ -125,6 +128,11 @@ public class ContactSettingsFragment extends SettingsFragment {
@Override
public void onBoolValueChanged(boolean newValue) {
mPrefs.enableChatRoomsShortcuts(newValue);
if (newValue) {
Compatibility.createChatShortcuts(getActivity());
} else {
Compatibility.removeChatShortcuts(getActivity());
}
}
});
}

View file

@ -94,7 +94,7 @@
<bool name="use_big_pictures_to_preview_images_file_transfers">true</bool>
<bool name="show_sip_uri_in_chat">false</bool>
<bool name="hide_empty_one_to_one_chat_rooms">true</bool>
<bool name="create_most_recent_chat_rooms_shortcuts">false</bool>
<bool name="create_most_recent_chat_rooms_shortcuts">true</bool>
<bool name="force_end_to_end_encryption_in_chat">false</bool>
<!-- Contacts -->