Merge pull request #5989 from osmandapp/init_telegram_app
Init telegram app
This commit is contained in:
commit
6a5bf91f7f
4 changed files with 33 additions and 3 deletions
|
@ -53,6 +53,15 @@
|
|||
|
||||
<receiver android:name=".OnTelegramServiceAlarmReceiver" />
|
||||
|
||||
<receiver
|
||||
android:name=".InitAppBroadcastReceiver"
|
||||
android:enabled="true"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="net.osmand.telegram.InitApp"/>
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<provider
|
||||
android:name="android.support.v4.content.FileProvider"
|
||||
android:authorities="net.osmand.telegram.fileprovider"
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
package net.osmand.telegram
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
|
||||
class InitAppBroadcastReceiver : BroadcastReceiver() {
|
||||
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
// do nothing, TelegramApplication already initialized
|
||||
}
|
||||
}
|
|
@ -45,10 +45,8 @@ class TelegramApplication : Application(), OsmandHelperListener {
|
|||
osmandAidlHelper.listener = object : OsmandAidlHelper.OsmandHelperListener {
|
||||
override fun onOsmandConnectionStateChanged(connected: Boolean) {
|
||||
if (connected) {
|
||||
val basePackage = "net.osmand.telegram"
|
||||
val appPackage = if (BuildConfig.DEBUG) "$basePackage.debug" else basePackage
|
||||
osmandAidlHelper.setNavDrawerItems(
|
||||
appPackage,
|
||||
applicationContext.packageName,
|
||||
listOf(getString(R.string.app_name)),
|
||||
listOf("osmand_telegram://main_activity"),
|
||||
listOf("ic_action_location_sharing_app"),
|
||||
|
|
|
@ -3,6 +3,7 @@ package net.osmand.aidl;
|
|||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
|
@ -176,6 +177,7 @@ public class OsmandAidlApi {
|
|||
registerStopNavigationReceiver(mapActivity);
|
||||
registerMuteNavigationReceiver(mapActivity);
|
||||
registerUnmuteNavigationReceiver(mapActivity);
|
||||
initOsmandTelegram();
|
||||
}
|
||||
|
||||
public void onDestroyMapActivity(MapActivity mapActivity) {
|
||||
|
@ -197,6 +199,15 @@ public class OsmandAidlApi {
|
|||
return mapActivityActive;
|
||||
}
|
||||
|
||||
private void initOsmandTelegram() {
|
||||
String[] packages = new String[]{"net.osmand.telegram", "net.osmand.telegram.debug"};
|
||||
Intent intent = new Intent("net.osmand.telegram.InitApp");
|
||||
for (String pack : packages) {
|
||||
intent.setComponent(new ComponentName(pack, "net.osmand.telegram.InitAppBroadcastReceiver"));
|
||||
app.sendBroadcast(intent);
|
||||
}
|
||||
}
|
||||
|
||||
private void registerRefreshMapReceiver(MapActivity mapActivity) {
|
||||
final WeakReference<MapActivity> mapActivityRef = new WeakReference<>(mapActivity);
|
||||
BroadcastReceiver refreshMapReceiver = new BroadcastReceiver() {
|
||||
|
|
Loading…
Reference in a new issue