mirror of
https://github.com/DrKLO/Telegram.git
synced 2025-03-15 20:08:00 +01:00
Create two Gradle flavours, "standard" and "foss".
This change creates two different Gradle flavours: - standard: Telegram as was before this change. - foss: Telegram without HockeyApp and Google Play Services. To make future maintenance easier, I've implemented two service wrappers (HockeyServiceWrapper and LocationServiceWrapper), intended to remove build time dependencies without maintaining separate copies for both ApplicationActiviy and ChatActivity.
This commit is contained in:
parent
b220e7776b
commit
1109ccb314
16 changed files with 602 additions and 66 deletions
|
@ -31,8 +31,6 @@ tasks.withType(JavaCompile) {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
compile 'com.google.android.gms:play-services:4.0.+'
|
||||
compile 'net.hockeyapp.android:HockeySDK:3.0.1'
|
||||
compile 'com.android.support:support-v4:19.0.+'
|
||||
compile 'com.android.support:appcompat-v7:19.0.+'
|
||||
compile fileTree(dir: "$buildDir/native-libs", include: 'native-libs.jar')
|
||||
|
@ -42,6 +40,20 @@ android {
|
|||
compileSdkVersion 19
|
||||
buildToolsVersion '19.0.0'
|
||||
|
||||
productFlavors {
|
||||
standard {
|
||||
packageName 'org.telegram.ui.ApplicationLoader.standard'
|
||||
}
|
||||
foss {
|
||||
packageName 'org.telegram.ui.ApplicationLoader.foss'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
standardCompile 'com.google.android.gms:play-services:4.0.+'
|
||||
standardCompile 'net.hockeyapp.android:HockeySDK:3.0.1'
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
debug {
|
||||
storeFile file("debug.keystore")
|
||||
|
|
142
TMessagesProj/src/foss/AndroidManifest.xml
Normal file
142
TMessagesProj/src/foss/AndroidManifest.xml
Normal file
|
@ -0,0 +1,142 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.telegram.messenger"
|
||||
android:versionCode="131"
|
||||
android:versionName="1.3.7">
|
||||
|
||||
<supports-screens android:anyDensity="true"
|
||||
android:smallScreens="true"
|
||||
android:normalScreens="true"
|
||||
android:largeScreens="true"
|
||||
android:resizeable="true"
|
||||
android:xlargeScreens="true"/>
|
||||
|
||||
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="19" />
|
||||
|
||||
<uses-feature android:glEsVersion="0x00020000" android:required="true"/>
|
||||
<uses-feature android:name="android.hardware.telephony" android:required="false" />
|
||||
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
|
||||
<uses-feature android:name="android.hardware.camera" android:required="false" />
|
||||
<uses-feature android:name="android.hardware.wifi" android:required="false" />
|
||||
<uses-feature android:name="android.hardware.screen.PORTRAIT" android:required="false" />
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_SMS" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
||||
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
|
||||
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS"/>
|
||||
<uses-permission android:name="android.permission.READ_PROFILE"/>
|
||||
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS"/>
|
||||
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS"/>
|
||||
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS"/>
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/AppName"
|
||||
android:theme="@style/Theme.TMessages.Start"
|
||||
android:name="org.telegram.ui.ApplicationLoader"
|
||||
android:hardwareAccelerated="true"
|
||||
android:largeHeap="true">
|
||||
|
||||
<activity
|
||||
android:name="org.telegram.ui.LaunchActivity"
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.SEND"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
<data android:mimeType="image/*"/>
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.SEND"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
<data android:mimeType="video/*"/>
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.SEND"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
<data android:mimeType="text/plain"/>
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
<data android:mimeType="vnd.android.cursor.item/vnd.org.telegram.messenger.android.profile"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name="org.telegram.ui.LoginActivity"
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
|
||||
android:screenOrientation="portrait">
|
||||
</activity>
|
||||
<activity
|
||||
android:name="org.telegram.ui.CountrySelectActivity"
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
android:theme="@style/Theme.TMessages"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
|
||||
android:screenOrientation="portrait">
|
||||
</activity>
|
||||
<activity
|
||||
android:name="org.telegram.ui.IntroActivity"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
|
||||
android:screenOrientation="portrait">
|
||||
</activity>
|
||||
<activity
|
||||
android:name="org.telegram.ui.ApplicationActivity"
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
android:theme="@style/Theme.TMessages"
|
||||
android:hardwareAccelerated="true"
|
||||
android:launchMode="singleTask"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
|
||||
</activity>
|
||||
<activity
|
||||
android:name="org.telegram.ui.GalleryImageViewer"
|
||||
android:theme="@style/Theme.TMessages.Gallery"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
|
||||
</activity>
|
||||
|
||||
|
||||
<receiver android:name="org.telegram.messenger.SmsListener">
|
||||
<intent-filter>
|
||||
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<service android:name="org.telegram.messenger.AuthenticatorService"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.accounts.AccountAuthenticator"/>
|
||||
</intent-filter>
|
||||
<meta-data android:name="android.accounts.AccountAuthenticator"
|
||||
android:resource="@xml/auth"/>
|
||||
</service>
|
||||
|
||||
<service android:name="org.telegram.messenger.ContactsSyncAdapterService"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.content.SyncAdapter" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="android.content.SyncAdapter"
|
||||
android:resource="@xml/sync_contacts" />
|
||||
<meta-data android:name="android.provider.CONTACTS_STRUCTURE"
|
||||
android:resource="@xml/contacts" />
|
||||
</service>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
/*
|
||||
* This is the source code of Telegram for Android v. 1.3.2.
|
||||
* It is licensed under GNU GPL v. 2 or later.
|
||||
* You should have received a copy of the license in this archive (see LICENSE).
|
||||
*
|
||||
* Copyright Nikolai Kudashov, 2013.
|
||||
*/
|
||||
|
||||
package org.telegram.messenger;
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package org.telegram.messenger;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
|
||||
public class HockeyServiceWrapper {
|
||||
public static void registerCrashManager(Context context) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
public static void registerUpdateManager(Activity activity) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package org.telegram.messenger;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
|
||||
import org.telegram.ui.ApplicationActivity;
|
||||
|
||||
public class LocationServiceWrapper {
|
||||
public static boolean isGoogleMapsInstalled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void presentLocationView(ApplicationActivity parentActivity) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
|
@ -0,0 +1,124 @@
|
|||
/*
|
||||
* This is the source code of Telegram for Android v. 1.3.2.
|
||||
* It is licensed under GNU GPL v. 2 or later.
|
||||
* You should have received a copy of the license in this archive (see LICENSE).
|
||||
*
|
||||
* Copyright Nikolai Kudashov, 2013.
|
||||
*/
|
||||
|
||||
package org.telegram.ui;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.AsyncTask;
|
||||
import android.view.ViewConfiguration;
|
||||
|
||||
import org.telegram.PhoneFormat.PhoneFormat;
|
||||
import org.telegram.TL.TLRPC;
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.messenger.MessagesStorage;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.ui.Views.BaseFragment;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class ApplicationLoader extends Application {
|
||||
private AtomicInteger msgId = new AtomicInteger();
|
||||
private String regid;
|
||||
private String SENDER_ID = "760348033672";
|
||||
public static final String EXTRA_MESSAGE = "message";
|
||||
public static final String PROPERTY_REG_ID = "registration_id";
|
||||
private static final String PROPERTY_APP_VERSION = "appVersion";
|
||||
private static final int PLAY_SERVICES_RESOLUTION_REQUEST = 9000;
|
||||
public static long lastPauseTime;
|
||||
public static Bitmap cachedWallpaper = null;
|
||||
public static Context applicationContext;
|
||||
|
||||
public static ApplicationLoader Instance = null;
|
||||
|
||||
public static ArrayList<BaseFragment> fragmentsStack = new ArrayList<BaseFragment>();
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
Instance = this;
|
||||
|
||||
java.lang.System.setProperty("java.net.preferIPv4Stack", "true");
|
||||
java.lang.System.setProperty("java.net.preferIPv6Addresses", "false");
|
||||
|
||||
applicationContext = getApplicationContext();
|
||||
Utilities.getTypeface("fonts/rmedium.ttf");
|
||||
UserConfig.loadConfig();
|
||||
SharedPreferences preferences = getSharedPreferences("Notifications", MODE_PRIVATE);
|
||||
if (UserConfig.currentUser != null) {
|
||||
int value = preferences.getInt("version", 0);
|
||||
if (value != 15) {
|
||||
UserConfig.contactsHash = "";
|
||||
MessagesStorage.lastDateValue = 0;
|
||||
MessagesStorage.lastPtsValue = 0;
|
||||
MessagesStorage.lastSeqValue = 0;
|
||||
MessagesStorage.lastQtsValue = 0;
|
||||
UserConfig.saveConfig(false);
|
||||
MessagesStorage.Instance.cleanUp();
|
||||
ArrayList<TLRPC.User> users = new ArrayList<TLRPC.User>();
|
||||
users.add(UserConfig.currentUser);
|
||||
MessagesStorage.Instance.putUsersAndChats(users, null, true, true);
|
||||
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putInt("version", 15);
|
||||
editor.commit();
|
||||
} else {
|
||||
MessagesStorage init = MessagesStorage.Instance;
|
||||
}
|
||||
MessagesController.Instance.users.put(UserConfig.clientUserId, UserConfig.currentUser);
|
||||
} else {
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putInt("version", 15);
|
||||
editor.commit();
|
||||
}
|
||||
MessagesController.Instance.checkAppAccount();
|
||||
|
||||
try {
|
||||
ViewConfiguration config = ViewConfiguration.get(this);
|
||||
Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
|
||||
if(menuKeyField != null) {
|
||||
menuKeyField.setAccessible(true);
|
||||
menuKeyField.setBoolean(config, false);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
|
||||
FileLog.d("tmessages", "This build doesn't support Google Play Services.");
|
||||
|
||||
PhoneFormat format = PhoneFormat.Instance;
|
||||
|
||||
lastPauseTime = System.currentTimeMillis();
|
||||
FileLog.e("tmessages", "start application with time " + lastPauseTime);
|
||||
}
|
||||
|
||||
public static void resetLastPauseTime() {
|
||||
lastPauseTime = 0;
|
||||
ConnectionsManager.Instance.applicationMovedToForeground();
|
||||
}
|
||||
|
||||
public static int getAppVersion() {
|
||||
try {
|
||||
PackageInfo packageInfo = applicationContext.getPackageManager().getPackageInfo(applicationContext.getPackageName(), 0);
|
||||
return packageInfo.versionCode;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
throw new RuntimeException("Could not get package name: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
/*
|
||||
* This is the source code of Telegram for Android v. 1.3.2.
|
||||
* It is licensed under GNU GPL v. 2 or later.
|
||||
* You should have received a copy of the license in this archive (see LICENSE).
|
||||
*
|
||||
* Copyright Nikolai Kudashov, 2013.
|
||||
*/
|
||||
|
||||
package org.telegram.ui;
|
||||
|
|
@ -15,13 +15,9 @@
|
|||
|
||||
<uses-feature android:glEsVersion="0x00020000" android:required="true"/>
|
||||
<uses-feature android:name="android.hardware.telephony" android:required="false" />
|
||||
<uses-feature android:name="android.hardware.location.gps" android:required="false" />
|
||||
<uses-feature android:name="android.hardware.location.network" android:required="false" />
|
||||
<uses-feature android:name="android.hardware.location" android:required="false" />
|
||||
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
|
||||
<uses-feature android:name="android.hardware.camera" android:required="false" />
|
||||
<uses-feature android:name="android.hardware.wifi" android:required="false" />
|
||||
<uses-feature android:name="android.hardware.LOCATION" android:required="false" />
|
||||
<uses-feature android:name="android.hardware.screen.PORTRAIT" android:required="false" />
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
@ -29,14 +25,8 @@
|
|||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_SMS" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
|
||||
<uses-permission android:name="org.telegram.messenger.permission.MAPS_RECEIVE"/>
|
||||
<uses-permission android:name="org.telegram.messenger.permission.C2D_MESSAGE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
||||
|
@ -50,9 +40,6 @@
|
|||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
|
||||
<permission android:name="org.telegram.messenger.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
|
||||
<permission android:name="org.telegram.messenger.permission.C2D_MESSAGE" android:protectionLevel="signature" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
|
@ -62,8 +49,6 @@
|
|||
android:hardwareAccelerated="true"
|
||||
android:largeHeap="true">
|
||||
|
||||
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="your-google-maps-api-key-here" />
|
||||
|
||||
<activity
|
||||
android:name="org.telegram.ui.LaunchActivity"
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
|
@ -126,24 +111,12 @@
|
|||
</activity>
|
||||
|
||||
|
||||
<activity android:name="net.hockeyapp.android.UpdateActivity" />
|
||||
|
||||
<receiver android:name="org.telegram.messenger.SmsListener">
|
||||
<intent-filter>
|
||||
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<receiver
|
||||
android:name="org.telegram.messenger.GcmBroadcastReceiver"
|
||||
android:permission="com.google.android.c2dm.permission.SEND" >
|
||||
<intent-filter>
|
||||
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
|
||||
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
|
||||
<category android:name="org.telegram.messenger" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<service android:name="org.telegram.messenger.AuthenticatorService"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
|
@ -163,8 +136,6 @@
|
|||
<meta-data android:name="android.provider.CONTACTS_STRUCTURE"
|
||||
android:resource="@xml/contacts" />
|
||||
</service>
|
||||
|
||||
<uses-library android:name="com.google.android.maps" android:required="false"/>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
|
|
@ -29,6 +29,7 @@ import android.widget.TextView;
|
|||
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.HockeyServiceWrapper;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
|
@ -38,9 +39,6 @@ import org.telegram.objects.MessageObject;
|
|||
import org.telegram.ui.Views.BaseFragment;
|
||||
import org.telegram.ui.Views.NotificationView;
|
||||
|
||||
import net.hockeyapp.android.CrashManager;
|
||||
import net.hockeyapp.android.UpdateManager;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
|
@ -317,12 +315,12 @@ public class ApplicationActivity extends ActionBarActivity implements Notificati
|
|||
}
|
||||
|
||||
private void checkForCrashes() {
|
||||
CrashManager.register(this, ConnectionsManager.HOCKEY_APP_HASH);
|
||||
HockeyServiceWrapper.registerCrashManager(this);
|
||||
}
|
||||
|
||||
private void checkForUpdates() {
|
||||
if (ConnectionsManager.DEBUG_VERSION) {
|
||||
UpdateManager.register(this, ConnectionsManager.HOCKEY_APP_HASH);
|
||||
HockeyServiceWrapper.registerUpdateManager(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -70,6 +70,7 @@ import android.widget.TextView;
|
|||
import org.telegram.PhoneFormat.PhoneFormat;
|
||||
import org.telegram.TL.TLRPC;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.LocationServiceWrapper;
|
||||
import org.telegram.objects.MessageObject;
|
||||
import org.telegram.objects.PhotoObject;
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
|
@ -2567,11 +2568,11 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
|
|||
break;
|
||||
}
|
||||
case R.id.attach_location: {
|
||||
if (!isGoogleMapsInstalled()) {
|
||||
if (!LocationServiceWrapper.isGoogleMapsInstalled()) {
|
||||
askGoogleMapsInstallation();
|
||||
return true;
|
||||
}
|
||||
LocationActivity fragment = new LocationActivity();
|
||||
((ApplicationActivity)parentActivity).presentFragment(fragment, "location", false);
|
||||
LocationServiceWrapper.presentLocationView((ApplicationActivity) parentActivity);
|
||||
break;
|
||||
}
|
||||
case R.id.attach_document: {
|
||||
|
@ -2584,31 +2585,25 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
|
|||
return true;
|
||||
}
|
||||
|
||||
public boolean isGoogleMapsInstalled() {
|
||||
try {
|
||||
ApplicationInfo info = ApplicationLoader.applicationContext.getPackageManager().getApplicationInfo("com.google.android.apps.maps", 0 );
|
||||
return true;
|
||||
} catch(PackageManager.NameNotFoundException e) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
|
||||
builder.setMessage("Install Google Maps?");
|
||||
builder.setCancelable(true);
|
||||
builder.setPositiveButton(getStringEntry(R.string.OK), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
try {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.google.android.apps.maps"));
|
||||
startActivity(intent);
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
public void askGoogleMapsInstallation() {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
|
||||
builder.setMessage("Install Google Maps?");
|
||||
builder.setCancelable(true);
|
||||
builder.setPositiveButton(getStringEntry(R.string.OK), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
try {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.google.android.apps.maps"));
|
||||
startActivity(intent);
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(R.string.Cancel, null);
|
||||
visibleDialog = builder.create();
|
||||
visibleDialog.setCanceledOnTouchOutside(true);
|
||||
visibleDialog.show();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(R.string.Cancel, null);
|
||||
visibleDialog = builder.create();
|
||||
visibleDialog.setCanceledOnTouchOutside(true);
|
||||
visibleDialog.show();
|
||||
}
|
||||
|
||||
private boolean spanClicked(ListView list, View view, int textViewId) {
|
||||
|
@ -3628,12 +3623,12 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
|
|||
}
|
||||
if (message != null) {
|
||||
if (message.type == 4 || message.type == 5) {
|
||||
if (!isGoogleMapsInstalled()) {
|
||||
if (!LocationServiceWrapper.isGoogleMapsInstalled()) {
|
||||
askGoogleMapsInstallation();
|
||||
return;
|
||||
}
|
||||
NotificationCenter.Instance.addToMemCache(0, message);
|
||||
LocationActivity fragment = new LocationActivity();
|
||||
((ApplicationActivity)parentActivity).presentFragment(fragment, "location_view", false);
|
||||
LocationServiceWrapper.presentLocationView((ApplicationActivity) parentActivity);
|
||||
} else if (message.type == 2 || message.type == 3) {
|
||||
NotificationCenter.Instance.addToMemCache(51, message);
|
||||
Intent intent = new Intent(parentActivity, GalleryImageViewer.class);
|
||||
|
|
171
TMessagesProj/src/standard/AndroidManifest.xml
Normal file
171
TMessagesProj/src/standard/AndroidManifest.xml
Normal file
|
@ -0,0 +1,171 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.telegram.messenger"
|
||||
android:versionCode="131"
|
||||
android:versionName="1.3.7">
|
||||
|
||||
<supports-screens android:anyDensity="true"
|
||||
android:smallScreens="true"
|
||||
android:normalScreens="true"
|
||||
android:largeScreens="true"
|
||||
android:resizeable="true"
|
||||
android:xlargeScreens="true"/>
|
||||
|
||||
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="19" />
|
||||
|
||||
<uses-feature android:glEsVersion="0x00020000" android:required="true"/>
|
||||
<uses-feature android:name="android.hardware.telephony" android:required="false" />
|
||||
<uses-feature android:name="android.hardware.location.gps" android:required="false" />
|
||||
<uses-feature android:name="android.hardware.location.network" android:required="false" />
|
||||
<uses-feature android:name="android.hardware.location" android:required="false" />
|
||||
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
|
||||
<uses-feature android:name="android.hardware.camera" android:required="false" />
|
||||
<uses-feature android:name="android.hardware.wifi" android:required="false" />
|
||||
<uses-feature android:name="android.hardware.LOCATION" android:required="false" />
|
||||
<uses-feature android:name="android.hardware.screen.PORTRAIT" android:required="false" />
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_SMS" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
|
||||
<uses-permission android:name="org.telegram.messenger.permission.MAPS_RECEIVE"/>
|
||||
<uses-permission android:name="org.telegram.messenger.permission.C2D_MESSAGE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
||||
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
|
||||
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS"/>
|
||||
<uses-permission android:name="android.permission.READ_PROFILE"/>
|
||||
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS"/>
|
||||
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS"/>
|
||||
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS"/>
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
|
||||
<permission android:name="org.telegram.messenger.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
|
||||
<permission android:name="org.telegram.messenger.permission.C2D_MESSAGE" android:protectionLevel="signature" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/AppName"
|
||||
android:theme="@style/Theme.TMessages.Start"
|
||||
android:name="org.telegram.ui.ApplicationLoader"
|
||||
android:hardwareAccelerated="true"
|
||||
android:largeHeap="true">
|
||||
|
||||
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="your-google-maps-api-key-here" />
|
||||
|
||||
<activity
|
||||
android:name="org.telegram.ui.LaunchActivity"
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.SEND"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
<data android:mimeType="image/*"/>
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.SEND"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
<data android:mimeType="video/*"/>
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.SEND"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
<data android:mimeType="text/plain"/>
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
<data android:mimeType="vnd.android.cursor.item/vnd.org.telegram.messenger.android.profile"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name="org.telegram.ui.LoginActivity"
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
|
||||
android:screenOrientation="portrait">
|
||||
</activity>
|
||||
<activity
|
||||
android:name="org.telegram.ui.CountrySelectActivity"
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
android:theme="@style/Theme.TMessages"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
|
||||
android:screenOrientation="portrait">
|
||||
</activity>
|
||||
<activity
|
||||
android:name="org.telegram.ui.IntroActivity"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
|
||||
android:screenOrientation="portrait">
|
||||
</activity>
|
||||
<activity
|
||||
android:name="org.telegram.ui.ApplicationActivity"
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
android:theme="@style/Theme.TMessages"
|
||||
android:hardwareAccelerated="true"
|
||||
android:launchMode="singleTask"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
|
||||
</activity>
|
||||
<activity
|
||||
android:name="org.telegram.ui.GalleryImageViewer"
|
||||
android:theme="@style/Theme.TMessages.Gallery"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
|
||||
</activity>
|
||||
|
||||
|
||||
<activity android:name="net.hockeyapp.android.UpdateActivity" />
|
||||
|
||||
<receiver android:name="org.telegram.messenger.SmsListener">
|
||||
<intent-filter>
|
||||
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<receiver
|
||||
android:name="org.telegram.messenger.GcmBroadcastReceiver"
|
||||
android:permission="com.google.android.c2dm.permission.SEND" >
|
||||
<intent-filter>
|
||||
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
|
||||
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
|
||||
<category android:name="org.telegram.messenger" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<service android:name="org.telegram.messenger.AuthenticatorService"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.accounts.AccountAuthenticator"/>
|
||||
</intent-filter>
|
||||
<meta-data android:name="android.accounts.AccountAuthenticator"
|
||||
android:resource="@xml/auth"/>
|
||||
</service>
|
||||
|
||||
<service android:name="org.telegram.messenger.ContactsSyncAdapterService"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.content.SyncAdapter" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="android.content.SyncAdapter"
|
||||
android:resource="@xml/sync_contacts" />
|
||||
<meta-data android:name="android.provider.CONTACTS_STRUCTURE"
|
||||
android:resource="@xml/contacts" />
|
||||
</service>
|
||||
|
||||
<uses-library android:name="com.google.android.maps" android:required="false"/>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package org.telegram.messenger;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
|
||||
import net.hockeyapp.android.CrashManager;
|
||||
import net.hockeyapp.android.UpdateManager;
|
||||
|
||||
public class HockeyServiceWrapper {
|
||||
public static void registerCrashManager(Context context) {
|
||||
CrashManager.register(context, ConnectionsManager.HOCKEY_APP_HASH);
|
||||
}
|
||||
|
||||
public static void registerUpdateManager(Activity activity) {
|
||||
UpdateManager.register(activity, ConnectionsManager.HOCKEY_APP_HASH);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package org.telegram.messenger;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
|
||||
import org.telegram.ui.ApplicationActivity;
|
||||
import org.telegram.ui.ApplicationLoader;
|
||||
import org.telegram.ui.LocationActivity;
|
||||
|
||||
public class LocationServiceWrapper {
|
||||
private ApplicationActivity parentActivity;
|
||||
|
||||
// public LocationServiceWrapper(ApplicationActivity activity) {
|
||||
// parentActivity = activity;
|
||||
// }
|
||||
|
||||
public static boolean isGoogleMapsInstalled() {
|
||||
try {
|
||||
ApplicationInfo info = ApplicationLoader.applicationContext.getPackageManager().getApplicationInfo("com.google.android.apps.maps", 0 );
|
||||
return true;
|
||||
} catch(PackageManager.NameNotFoundException e) {
|
||||
// AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
|
||||
// builder.setMessage("Install Google Maps?");
|
||||
// builder.setCancelable(true);
|
||||
// builder.setPositiveButton(getStringEntry(R.string.OK), new DialogInterface.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(DialogInterface dialogInterface, int i) {
|
||||
// try {
|
||||
// Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.google.android.apps.maps"));
|
||||
// startActivity(intent);
|
||||
// } catch (Exception e) {
|
||||
// FileLog.e("tmessages", e);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// builder.setNegativeButton(R.string.Cancel, null);
|
||||
// visibleDialog = builder.create();
|
||||
// visibleDialog.setCanceledOnTouchOutside(true);
|
||||
// visibleDialog.show();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void presentLocationView(ApplicationActivity parentActivity) {
|
||||
LocationActivity fragment = new LocationActivity();
|
||||
parentActivity.presentFragment(fragment, "location", false);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue