diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 41ae4ce7f..2298b6284 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -52,8 +52,8 @@
-
-
+
+
@@ -79,6 +79,8 @@
+
+
@@ -127,41 +129,38 @@
+ android:launchMode="singleTask"
+ android:showOnLockScreen="true"
+ android:supportsPictureInPicture="true"
+ android:taskAffinity=".call"
+ android:theme="@style/AppTheme.CallLauncher" />
+ android:launchMode="singleTask"
+ android:showOnLockScreen="true"
+ android:supportsPictureInPicture="true"
+ android:taskAffinity=".call"
+ android:theme="@style/AppTheme.CallLauncher" />
-
+ android:configChanges="orientation|keyboardHidden|screenSize"
+ android:theme="@style/FullScreenImageTheme">
-
+ android:configChanges="orientation|keyboardHidden|screenSize"
+ android:theme="@style/FullScreenMediaTheme">
-
+ android:configChanges="orientation|keyboardHidden|screenSize"
+ android:theme="@style/FullScreenTextTheme">
+ android:theme="@style/AppTheme" />
diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java b/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java
index dfb72b333..000a61942 100644
--- a/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java
+++ b/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java
@@ -93,6 +93,7 @@ import com.nextcloud.talk.utils.DisplayUtils;
import com.nextcloud.talk.utils.UriUtils;
import com.nextcloud.talk.utils.bundle.BundleKeys;
import com.nextcloud.talk.utils.database.user.UserUtils;
+import com.nextcloud.talk.utils.power.PowerManagerUtil;
import com.nextcloud.talk.utils.preferences.AppPreferences;
import com.webianks.library.PopupBubble;
import com.yarolegovich.lovelydialog.LovelySaveStateHandler;
@@ -253,6 +254,10 @@ public class ConversationsListController extends BaseController implements Searc
adapter.addListener(this);
prepareViews();
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+ new PowerManagerUtil().askForBatteryOptimization(getActivity());
+ }
}
private void loadUserAvatar(MaterialButton button) {
@@ -427,8 +432,8 @@ public class ConversationsListController extends BaseController implements Searc
MainActivity activity = (MainActivity) getActivity();
if (activity != null) {
activity.binding.appBar.setStateListAnimator(AnimatorInflater.loadStateListAnimator(
- activity.binding.appBar.getContext(),
- R.animator.appbar_elevation_off)
+ activity.binding.appBar.getContext(),
+ R.animator.appbar_elevation_off)
);
activity.binding.toolbar.setVisibility(View.GONE);
activity.binding.searchToolbar.setVisibility(View.VISIBLE);
@@ -644,8 +649,8 @@ public class ConversationsListController extends BaseController implements Searc
List openConversationItems = new ArrayList<>();
openConversationsQueryDisposable = ncApi.getOpenConversations(
- credentials,
- ApiUtils.getUrlForOpenConversations(apiVersion, currentUser.getBaseUrl()))
+ credentials,
+ ApiUtils.getUrlForOpenConversations(apiVersion, currentUser.getBaseUrl()))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(roomsOverall -> {
@@ -690,7 +695,7 @@ public class ConversationsListController extends BaseController implements Searc
if (getParentController() != null && getParentController().getRouter() != null) {
Log.d(TAG, "Starting reauth webview via getParentController()");
getParentController().getRouter().pushController((RouterTransaction.with
- (new WebViewLoginController(currentUser.getBaseUrl(), true))
+ (new WebViewLoginController(currentUser.getBaseUrl(), true))
.pushChangeHandler(new VerticalChangeHandler())
.popChangeHandler(new VerticalChangeHandler())));
} else {
@@ -1178,7 +1183,7 @@ public class ConversationsListController extends BaseController implements Searc
onAttach(getView());
} else if (!otherUserExists) {
getRouter().setRoot(RouterTransaction.with(
- new ServerSelectionController())
+ new ServerSelectionController())
.pushChangeHandler(new VerticalChangeHandler())
.popChangeHandler(new VerticalChangeHandler()));
}
@@ -1188,7 +1193,7 @@ public class ConversationsListController extends BaseController implements Searc
@Override
public void onClick(View v) {
getRouter().pushController(RouterTransaction.with(
- new WebViewLoginController(currentUser.getBaseUrl(), true))
+ new WebViewLoginController(currentUser.getBaseUrl(), true))
.pushChangeHandler(new VerticalChangeHandler())
.popChangeHandler(new VerticalChangeHandler()));
}
@@ -1221,7 +1226,7 @@ public class ConversationsListController extends BaseController implements Searc
onAttach(getView());
} else if (!otherUserExists) {
getRouter().setRoot(RouterTransaction.with(
- new ServerSelectionController())
+ new ServerSelectionController())
.pushChangeHandler(new VerticalChangeHandler())
.popChangeHandler(new VerticalChangeHandler()));
}
diff --git a/app/src/main/java/com/nextcloud/talk/utils/power/PowerManagerUtil.kt b/app/src/main/java/com/nextcloud/talk/utils/power/PowerManagerUtil.kt
new file mode 100644
index 000000000..e4634baab
--- /dev/null
+++ b/app/src/main/java/com/nextcloud/talk/utils/power/PowerManagerUtil.kt
@@ -0,0 +1,57 @@
+package com.nextcloud.talk.utils.power
+
+import android.annotation.SuppressLint
+import android.content.Context
+import android.content.Context.POWER_SERVICE
+import android.content.Intent
+import android.net.Uri
+import android.os.Build
+import android.os.PowerManager
+import android.provider.Settings
+import androidx.annotation.RequiresApi
+import androidx.appcompat.app.AlertDialog
+import androidx.lifecycle.LifecycleObserver
+import com.nextcloud.talk.BuildConfig
+import com.nextcloud.talk.R
+
+class PowerManagerUtil : LifecycleObserver {
+
+ @RequiresApi(Build.VERSION_CODES.M)
+ fun askForBatteryOptimization(context: Context) {
+ if (checkIfBatteryOptimizationEnabled(context)) {
+ val alertDialogBuilder = AlertDialog.Builder(context, R.style.Theme_ownCloud_Dialog)
+ .setTitle("Battery optimization")
+ .setMessage(
+ "Your device may have battery optimization enabled. Notifications work only properly if " +
+ "you exclude this app from it."
+ )
+ .setPositiveButton("disable") { _, _ ->
+ @SuppressLint("BatteryLife") val intent = Intent(
+ Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS,
+ Uri.parse("package:" + BuildConfig.APPLICATION_ID)
+ )
+ context.startActivity(intent)
+ }
+ .setNeutralButton("close") { dialog, _ -> dialog.dismiss() }
+ alertDialogBuilder.show()
+ }
+ }
+
+ /**
+ * Check if battery optimization is enabled. If unknown, fallback to true.
+ *
+ * @return true if battery optimization is enabled
+ */
+ @RequiresApi(Build.VERSION_CODES.M)
+ private fun checkIfBatteryOptimizationEnabled(context: Context): Boolean {
+ val powerManager = context.getSystemService(POWER_SERVICE) as PowerManager?
+ return when {
+ powerManager != null -> !powerManager.isIgnoringBatteryOptimizations(BuildConfig.APPLICATION_ID)
+ else -> true
+ }
+ }
+
+ companion object {
+ private val TAG = PowerManagerUtil::class.simpleName
+ }
+}
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index d16b13034..d7ed97275 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -122,6 +122,27 @@
- @color/fontAppbar
+
+
+
+
+
+
+