Java Code Examples for org.telegram.messenger.AndroidUtilities#checkDisplaySize()

The following examples show how to use org.telegram.messenger.AndroidUtilities#checkDisplaySize() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExternalActionActivity.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onConfigurationChanged(Configuration newConfig) {
    AndroidUtilities.checkDisplaySize(this, newConfig);
    super.onConfigurationChanged(newConfig);
    fixLayout();
}
 
Example 2
Source File: ShareActivity.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState)
{
    ApplicationLoader.postInitApplication();
    AndroidUtilities.checkDisplaySize(this, getResources().getConfiguration());
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setTheme(R.style.Theme_TMessages_Transparent);
    super.onCreate(savedInstanceState);
    setContentView(new View(this), new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

    Intent intent = getIntent();
    if (intent == null || !Intent.ACTION_VIEW.equals(intent.getAction()) || intent.getData() == null)
    {
        finish();
        return;
    }
    Uri data = intent.getData();
    String scheme = data.getScheme();
    String url = data.toString();
    String hash = data.getQueryParameter("hash");
    if (!"tgb".equals(scheme) || !url.toLowerCase().startsWith("tgb://share_game_score") || TextUtils.isEmpty(hash))
    {
        finish();
        return;
    }

    SharedPreferences sharedPreferences = ApplicationLoader.applicationContext.getSharedPreferences("botshare", Activity.MODE_PRIVATE);
    String message = sharedPreferences.getString(hash + "_m", null);
    if (TextUtils.isEmpty(message))
    {
        finish();
        return;
    }
    SerializedData serializedData = new SerializedData(Utilities.hexToBytes(message));
    TLRPC.Message mess = TLRPC.Message.TLdeserialize(serializedData, serializedData.readInt32(false), false);
    mess.readAttachPath(serializedData, 0);
    serializedData.cleanup();
    if (mess == null)
    {
        finish();
        return;
    }
    String link = sharedPreferences.getString(hash + "_link", null);
    MessageObject messageObject = new MessageObject(UserConfig.selectedAccount, mess, false);
    messageObject.messageOwner.with_my_score = true;

    try
    {
        visibleDialog = ShareAlert.createShareAlert(this, messageObject, null, false, link, false);
        visibleDialog.setCanceledOnTouchOutside(true);
        visibleDialog.setOnDismissListener(new DialogInterface.OnDismissListener()
        {
            @Override
            public void onDismiss(DialogInterface dialog)
            {
                if (!isFinishing())
                {
                    finish();
                }
                visibleDialog = null;
            }
        });
        visibleDialog.show();
    }
    catch (Exception e)
    {
        FileLog.e(e);
        finish();
    }
}
 
Example 3
Source File: PopupNotificationActivity.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    AndroidUtilities.checkDisplaySize(this, newConfig);
    fixLayout();
}
 
Example 4
Source File: ExternalActionActivity.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onConfigurationChanged(Configuration newConfig) {
    AndroidUtilities.checkDisplaySize(this, newConfig);
    super.onConfigurationChanged(newConfig);
    fixLayout();
}
 
Example 5
Source File: ShareActivity.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState)
{
    ApplicationLoader.postInitApplication();
    AndroidUtilities.checkDisplaySize(this, getResources().getConfiguration());
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setTheme(R.style.Theme_TMessages_Transparent);
    super.onCreate(savedInstanceState);
    setContentView(new View(this), new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

    Intent intent = getIntent();
    if (intent == null || !Intent.ACTION_VIEW.equals(intent.getAction()) || intent.getData() == null)
    {
        finish();
        return;
    }
    Uri data = intent.getData();
    String scheme = data.getScheme();
    String url = data.toString();
    String hash = data.getQueryParameter("hash");
    if (!"tgb".equals(scheme) || !url.toLowerCase().startsWith("tgb://share_game_score") || TextUtils.isEmpty(hash))
    {
        finish();
        return;
    }

    SharedPreferences sharedPreferences = ApplicationLoader.applicationContext.getSharedPreferences("botshare", Activity.MODE_PRIVATE);
    String message = sharedPreferences.getString(hash + "_m", null);
    if (TextUtils.isEmpty(message))
    {
        finish();
        return;
    }
    SerializedData serializedData = new SerializedData(Utilities.hexToBytes(message));
    TLRPC.Message mess = TLRPC.Message.TLdeserialize(serializedData, serializedData.readInt32(false), false);
    mess.readAttachPath(serializedData, 0);
    serializedData.cleanup();
    if (mess == null)
    {
        finish();
        return;
    }
    String link = sharedPreferences.getString(hash + "_link", null);
    MessageObject messageObject = new MessageObject(UserConfig.selectedAccount, mess, false);
    messageObject.messageOwner.with_my_score = true;

    try
    {
        visibleDialog = ShareAlert.createShareAlert(this, messageObject, null, false, link, false);
        visibleDialog.setCanceledOnTouchOutside(true);
        visibleDialog.setOnDismissListener(new DialogInterface.OnDismissListener()
        {
            @Override
            public void onDismiss(DialogInterface dialog)
            {
                if (!isFinishing())
                {
                    finish();
                }
                visibleDialog = null;
            }
        });
        visibleDialog.show();
    }
    catch (Exception e)
    {
        FileLog.e(e);
        finish();
    }
}
 
Example 6
Source File: PopupNotificationActivity.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    AndroidUtilities.checkDisplaySize(this, newConfig);
    fixLayout();
}
 
Example 7
Source File: ExternalActionActivity.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onConfigurationChanged(android.content.res.Configuration newConfig) {
    AndroidUtilities.checkDisplaySize(this, newConfig);
    super.onConfigurationChanged(newConfig);
    fixLayout();
}
 
Example 8
Source File: ShareActivity.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    ApplicationLoader.postInitApplication();
    AndroidUtilities.checkDisplaySize(this, getResources().getConfiguration());
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setTheme(R.style.Theme_TMessages_Transparent);
    super.onCreate(savedInstanceState);
    setContentView(new View(this), new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

    Intent intent = getIntent();
    if (intent == null || !Intent.ACTION_VIEW.equals(intent.getAction()) || intent.getData() == null) {
        finish();
        return;
    }
    Uri data = intent.getData();
    String scheme = data.getScheme();
    String url = data.toString();
    String hash = data.getQueryParameter("hash");
    if (!"tgb".equals(scheme) || !url.toLowerCase().startsWith("tgb://share_game_score") || TextUtils.isEmpty(hash)) {
        finish();
        return;
    }

    SharedPreferences sharedPreferences = ApplicationLoader.applicationContext.getSharedPreferences("botshare", Activity.MODE_PRIVATE);
    String message = sharedPreferences.getString(hash + "_m", null);
    if (TextUtils.isEmpty(message)) {
        finish();
        return;
    }
    SerializedData serializedData = new SerializedData(Utilities.hexToBytes(message));
    TLRPC.Message mess = TLRPC.Message.TLdeserialize(serializedData, serializedData.readInt32(false), false);
    mess.readAttachPath(serializedData, 0);
    serializedData.cleanup();
    if (mess == null) {
        finish();
        return;
    }
    String link = sharedPreferences.getString(hash + "_link", null);
    MessageObject messageObject = new MessageObject(UserConfig.selectedAccount, mess, false);
    messageObject.messageOwner.with_my_score = true;

    try {
        visibleDialog = ShareAlert.createShareAlert(this, messageObject, null, false, link, false);
        visibleDialog.setCanceledOnTouchOutside(true);
        visibleDialog.setOnDismissListener(dialog -> {
            if (!isFinishing()) {
                finish();
            }
            visibleDialog = null;
        });
        visibleDialog.show();
    } catch (Exception e) {
        FileLog.e(e);
        finish();
    }
}
 
Example 9
Source File: PopupNotificationActivity.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    AndroidUtilities.checkDisplaySize(this, newConfig);
    fixLayout();
}
 
Example 10
Source File: ExternalActionActivity.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onConfigurationChanged(android.content.res.Configuration newConfig) {
    AndroidUtilities.checkDisplaySize(this, newConfig);
    super.onConfigurationChanged(newConfig);
    fixLayout();
}
 
Example 11
Source File: ShareActivity.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    ApplicationLoader.postInitApplication();
    AndroidUtilities.checkDisplaySize(this, getResources().getConfiguration());
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setTheme(R.style.Theme_TMessages_Transparent);
    super.onCreate(savedInstanceState);
    setContentView(new View(this), new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

    Intent intent = getIntent();
    if (intent == null || !Intent.ACTION_VIEW.equals(intent.getAction()) || intent.getData() == null) {
        finish();
        return;
    }
    Uri data = intent.getData();
    String scheme = data.getScheme();
    String url = data.toString();
    String hash = data.getQueryParameter("hash");
    if (!"tgb".equals(scheme) || !url.toLowerCase().startsWith("tgb://share_game_score") || TextUtils.isEmpty(hash)) {
        finish();
        return;
    }

    SharedPreferences sharedPreferences = ApplicationLoader.applicationContext.getSharedPreferences("botshare", Activity.MODE_PRIVATE);
    String message = sharedPreferences.getString(hash + "_m", null);
    if (TextUtils.isEmpty(message)) {
        finish();
        return;
    }
    SerializedData serializedData = new SerializedData(Utilities.hexToBytes(message));
    TLRPC.Message mess = TLRPC.Message.TLdeserialize(serializedData, serializedData.readInt32(false), false);
    mess.readAttachPath(serializedData, 0);
    serializedData.cleanup();
    if (mess == null) {
        finish();
        return;
    }
    String link = sharedPreferences.getString(hash + "_link", null);
    MessageObject messageObject = new MessageObject(UserConfig.selectedAccount, mess, false);
    messageObject.messageOwner.with_my_score = true;

    try {
        visibleDialog = ShareAlert.createShareAlert(this, messageObject, null, false, link, false);
        visibleDialog.setCanceledOnTouchOutside(true);
        visibleDialog.setOnDismissListener(dialog -> {
            if (!isFinishing()) {
                finish();
            }
            visibleDialog = null;
        });
        visibleDialog.show();
    } catch (Exception e) {
        FileLog.e(e);
        finish();
    }
}
 
Example 12
Source File: PopupNotificationActivity.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    AndroidUtilities.checkDisplaySize(this, newConfig);
    fixLayout();
}