Skip to content

Commit

Permalink
Bots changed, stickers added.
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg Isupov committed Oct 13, 2015
1 parent 433cf84 commit 118970b
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ public class BotSubscriber2 {
botNames.add("tahminetbot");
botNames.add("fenerbahce_bot");
botNames.add("fenerbahce_vote_bot");
botNames.add("fenetestbot");
botNames.add("fenerbahcebetsbot");
botNames.add("LookALikeBot");
}

public void init() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Copyright (c) 2015 Yandex LLC. All rights reserved.
// Author: Oleg Isupov <[email protected]>

package org.telegram.Ytils;

import android.content.Context;

import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.query.StickersQuery;
import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.RequestDelegate;
import org.telegram.tgnet.TLObject;
import org.telegram.tgnet.TLRPC;

public class StickersManager {

private static final String[] STICKER_SETS = new String[]{"fngrm_1", "fngrm_2"};

public static final StickersManager INSTANCE = new StickersManager();

private boolean started;
private int counter = STICKER_SETS.length;

public void installStickers(final Context context) {
if (started) {
return;
}
started = true;

if (context.getSharedPreferences("YandexPreferences", Context.MODE_PRIVATE)
.getBoolean("StickersInstalled", false)) {
return;
}

for (int i = 0; i < STICKER_SETS.length; i++) {
TLRPC.TL_inputStickerSetShortName stickerset = new TLRPC.TL_inputStickerSetShortName();
stickerset.short_name = STICKER_SETS[i];
TLRPC.TL_messages_installStickerSet req = new TLRPC.TL_messages_installStickerSet();
req.stickerset = stickerset;
ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() {
@Override
public void run(final TLObject response, final TLRPC.TL_error error) {
if (error == null) {
checkAllStickersInstalled(context);
}
}
});
}
}

private void checkAllStickersInstalled(final Context context) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
counter--;
if (counter == 0) {
StickersQuery.loadStickers(false, true);
// context.getSharedPreferences("YandexPreferences", Context.MODE_PRIVATE).edit()
// .putBoolean("StickersInstalled", true);
}
}
});
}

}
22 changes: 6 additions & 16 deletions TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@

import com.yandex.metrica.YandexMetrica;

import org.telegram.Ytils.StickersManager;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.PhoneFormat.PhoneFormat;
import org.telegram.messenger.ChatObject;
Expand Down Expand Up @@ -477,28 +478,17 @@ public void onClick(View v) {
ViewServer.get(this).addWindow(this);
}*/
if (!mainFragmentsStack.isEmpty()) {
TLRPC.TL_inputStickerSetShortName stickerset = new TLRPC.TL_inputStickerSetShortName();
// stickerset.short_name = "footbalistafa1";
stickerset.short_name = "fngr_1";
TLRPC.TL_messages_installStickerSet req = new TLRPC.TL_messages_installStickerSet();
req.stickerset = stickerset;
ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() {
@Override
public void run(TLObject response, final TLRPC.TL_error error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
StickersQuery.loadStickers(false, true);
}
});
}
});
StickersManager.INSTANCE.installStickers(ApplicationLoader.applicationContext);
}

handleIntent(getIntent(), false, savedInstanceState != null, false);
needLayout();
}

private void installStickerSet() {

}

private void showPasscodeActivity() {
if (passcodeView == null) {
return;
Expand Down

0 comments on commit 118970b

Please sign in to comment.