do not bother with battery-optimisation just after first start

This commit is contained in:
B. Petersen
2019-02-12 17:13:20 +01:00
parent 21be2fd69c
commit e501b86472
@@ -16,6 +16,7 @@ import android.support.v4.content.ContextCompat;
import android.view.View;
import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.connect.DcHelper;
import org.thoughtcrime.securesms.util.Prefs;
@SuppressLint("BatteryLife")
@@ -61,6 +62,18 @@ public class DozeReminder extends Reminder {
return false;
}
// if the chatlist is empty, just after installation,
// do not bother with battery, let the user check out other things first.
try {
int numberOfChats = DcHelper.getContext(context).getChatlist(0, null, 0).getCnt();
if (numberOfChats == 0) {
return false;
}
}
catch(Exception e) {
e.printStackTrace();
}
return true; // yip, asking for disabling battery optimisations makes sense
}
}