2013-10-25 17:19:00 +02:00
|
|
|
/*
|
2015-10-29 18:10:07 +01:00
|
|
|
* This is the source code of Telegram for Android v. 3.x.x.
|
2013-10-25 17:19:00 +02:00
|
|
|
* It is licensed under GNU GPL v. 2 or later.
|
|
|
|
* You should have received a copy of the license in this archive (see LICENSE).
|
|
|
|
*
|
2015-10-29 18:10:07 +01:00
|
|
|
* Copyright Nikolai Kudashov, 2013-2015.
|
2013-10-25 17:19:00 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
package org.telegram.ui;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.os.Bundle;
|
2014-11-19 16:17:24 +01:00
|
|
|
import android.view.MotionEvent;
|
2013-10-25 17:19:00 +02:00
|
|
|
import android.view.Surface;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.ViewTreeObserver;
|
|
|
|
import android.view.WindowManager;
|
2014-11-10 12:05:22 +01:00
|
|
|
import android.widget.ImageView;
|
2013-10-25 17:19:00 +02:00
|
|
|
import android.widget.LinearLayout;
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
2015-09-24 22:52:02 +02:00
|
|
|
import org.telegram.messenger.AndroidUtilities;
|
|
|
|
import org.telegram.messenger.LocaleController;
|
2014-12-01 18:56:31 +01:00
|
|
|
import org.telegram.messenger.ApplicationLoader;
|
2015-09-24 22:52:02 +02:00
|
|
|
import org.telegram.tgnet.TLRPC;
|
|
|
|
import org.telegram.messenger.MessagesController;
|
2013-10-25 17:19:00 +02:00
|
|
|
import org.telegram.messenger.R;
|
2014-11-13 21:10:14 +01:00
|
|
|
import org.telegram.ui.ActionBar.ActionBar;
|
|
|
|
import org.telegram.ui.ActionBar.BaseFragment;
|
2014-12-01 18:56:31 +01:00
|
|
|
import org.telegram.ui.Components.IdenticonDrawable;
|
2013-10-25 17:19:00 +02:00
|
|
|
|
|
|
|
public class IdenticonActivity extends BaseFragment {
|
|
|
|
private int chat_id;
|
|
|
|
|
2014-06-04 01:31:48 +02:00
|
|
|
public IdenticonActivity(Bundle args) {
|
|
|
|
super(args);
|
|
|
|
}
|
|
|
|
|
2013-10-25 17:19:00 +02:00
|
|
|
@Override
|
|
|
|
public boolean onFragmentCreate() {
|
|
|
|
chat_id = getArguments().getInt("chat_id");
|
|
|
|
return super.onFragmentCreate();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-07-22 20:56:37 +02:00
|
|
|
public View createView(Context context) {
|
2015-04-09 20:00:14 +02:00
|
|
|
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
|
|
|
|
actionBar.setAllowOverlayTitle(true);
|
|
|
|
actionBar.setTitle(LocaleController.getString("EncryptionKey", R.string.EncryptionKey));
|
2013-10-25 17:19:00 +02:00
|
|
|
|
2015-04-09 20:00:14 +02:00
|
|
|
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
|
|
|
|
@Override
|
|
|
|
public void onItemClick(int id) {
|
|
|
|
if (id == -1) {
|
|
|
|
finishFragment();
|
2014-06-04 01:31:48 +02:00
|
|
|
}
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
2015-04-09 20:00:14 +02:00
|
|
|
});
|
2014-11-19 16:17:24 +01:00
|
|
|
|
2015-07-22 20:56:37 +02:00
|
|
|
fragmentView = getParentActivity().getLayoutInflater().inflate(R.layout.identicon_layout, null, false);
|
2015-04-09 20:00:14 +02:00
|
|
|
ImageView identiconView = (ImageView) fragmentView.findViewById(R.id.identicon_view);
|
|
|
|
TextView textView = (TextView) fragmentView.findViewById(R.id.identicon_text);
|
|
|
|
TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance().getEncryptedChat(chat_id);
|
|
|
|
if (encryptedChat != null) {
|
|
|
|
IdenticonDrawable drawable = new IdenticonDrawable();
|
|
|
|
identiconView.setImageDrawable(drawable);
|
|
|
|
drawable.setEncryptedChat(encryptedChat);
|
|
|
|
TLRPC.User user = MessagesController.getInstance().getUser(encryptedChat.user_id);
|
|
|
|
textView.setText(AndroidUtilities.replaceTags(LocaleController.formatString("EncryptionKeyDescription", R.string.EncryptionKeyDescription, user.first_name, user.first_name)));
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
2015-04-09 20:00:14 +02:00
|
|
|
|
|
|
|
fragmentView.setOnTouchListener(new View.OnTouchListener() {
|
|
|
|
@Override
|
|
|
|
public boolean onTouch(View v, MotionEvent event) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2013-10-25 17:19:00 +02:00
|
|
|
return fragmentView;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onConfigurationChanged(android.content.res.Configuration newConfig) {
|
|
|
|
super.onConfigurationChanged(newConfig);
|
|
|
|
fixLayout();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onResume() {
|
2014-06-04 18:00:42 +02:00
|
|
|
super.onResume();
|
2013-10-25 17:19:00 +02:00
|
|
|
fixLayout();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void fixLayout() {
|
2014-06-04 01:31:48 +02:00
|
|
|
ViewTreeObserver obs = fragmentView.getViewTreeObserver();
|
|
|
|
obs.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
|
|
|
|
@Override
|
|
|
|
public boolean onPreDraw() {
|
2015-06-29 19:12:11 +02:00
|
|
|
if (fragmentView == null) {
|
2014-06-07 01:35:21 +02:00
|
|
|
return true;
|
|
|
|
}
|
2015-06-29 19:12:11 +02:00
|
|
|
fragmentView.getViewTreeObserver().removeOnPreDrawListener(this);
|
2014-06-04 01:31:48 +02:00
|
|
|
LinearLayout layout = (LinearLayout)fragmentView;
|
2014-12-01 18:56:31 +01:00
|
|
|
WindowManager manager = (WindowManager) ApplicationLoader.applicationContext.getSystemService(Context.WINDOW_SERVICE);
|
2014-06-04 01:31:48 +02:00
|
|
|
int rotation = manager.getDefaultDisplay().getRotation();
|
|
|
|
|
|
|
|
if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) {
|
|
|
|
layout.setOrientation(LinearLayout.HORIZONTAL);
|
|
|
|
} else {
|
|
|
|
layout.setOrientation(LinearLayout.VERTICAL);
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
|
2014-06-04 01:31:48 +02:00
|
|
|
fragmentView.setPadding(fragmentView.getPaddingLeft(), 0, fragmentView.getPaddingRight(), fragmentView.getPaddingBottom());
|
2015-06-29 19:12:11 +02:00
|
|
|
return true;
|
2014-06-04 01:31:48 +02:00
|
|
|
}
|
|
|
|
});
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
}
|