2013-10-25 15:19:00 +00:00
|
|
|
/*
|
2013-12-20 19:25:49 +00:00
|
|
|
* This is the source code of Telegram for Android v. 1.3.2.
|
2013-10-25 15:19:00 +00: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).
|
|
|
|
*
|
|
|
|
* Copyright Nikolai Kudashov, 2013.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package org.telegram.ui;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.text.Html;
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
import android.view.Surface;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.ViewGroup;
|
|
|
|
import android.view.ViewTreeObserver;
|
|
|
|
import android.view.WindowManager;
|
|
|
|
import android.widget.LinearLayout;
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
2014-03-22 22:31:55 +00:00
|
|
|
import org.telegram.messenger.LocaleController;
|
2014-02-28 22:28:25 +00:00
|
|
|
import org.telegram.messenger.TLRPC;
|
2013-10-25 15:19:00 +00:00
|
|
|
import org.telegram.messenger.MessagesController;
|
|
|
|
import org.telegram.messenger.R;
|
2013-12-26 16:46:13 +00:00
|
|
|
import org.telegram.messenger.Utilities;
|
2014-06-03 23:31:48 +00:00
|
|
|
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
|
|
|
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
2013-10-25 15:19:00 +00:00
|
|
|
import org.telegram.ui.Views.IdenticonView;
|
|
|
|
|
|
|
|
public class IdenticonActivity extends BaseFragment {
|
|
|
|
private int chat_id;
|
|
|
|
|
2014-06-03 23:31:48 +00:00
|
|
|
public IdenticonActivity(Bundle args) {
|
|
|
|
super(args);
|
|
|
|
}
|
|
|
|
|
2013-10-25 15:19:00 +00:00
|
|
|
@Override
|
|
|
|
public boolean onFragmentCreate() {
|
|
|
|
chat_id = getArguments().getInt("chat_id");
|
|
|
|
return super.onFragmentCreate();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-06-03 23:31:48 +00:00
|
|
|
public View createView(LayoutInflater inflater, ViewGroup container) {
|
|
|
|
if (fragmentView == null) {
|
2014-06-12 01:13:15 +00:00
|
|
|
actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back);
|
2014-06-03 23:31:48 +00:00
|
|
|
actionBarLayer.setTitle(LocaleController.getString("EncryptionKey", R.string.EncryptionKey));
|
|
|
|
actionBarLayer.setTitleIcon(R.drawable.ic_lock_white, Utilities.dp(4));
|
2013-10-25 15:19:00 +00:00
|
|
|
|
2014-06-03 23:31:48 +00:00
|
|
|
actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() {
|
|
|
|
@Override
|
|
|
|
public void onItemClick(int id) {
|
|
|
|
if (id == -1) {
|
|
|
|
finishFragment();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2013-10-25 15:19:00 +00:00
|
|
|
|
|
|
|
fragmentView = inflater.inflate(R.layout.identicon_layout, container, false);
|
|
|
|
IdenticonView identiconView = (IdenticonView) fragmentView.findViewById(R.id.identicon_view);
|
|
|
|
TextView textView = (TextView)fragmentView.findViewById(R.id.identicon_text);
|
2014-03-22 22:31:55 +00:00
|
|
|
TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance().encryptedChats.get(chat_id);
|
2013-10-25 15:19:00 +00:00
|
|
|
if (encryptedChat != null) {
|
|
|
|
identiconView.setBytes(encryptedChat.auth_key);
|
2014-03-22 22:31:55 +00:00
|
|
|
TLRPC.User user = MessagesController.getInstance().users.get(encryptedChat.user_id);
|
|
|
|
textView.setText(Html.fromHtml(LocaleController.formatString("EncryptionKeyDescription", R.string.EncryptionKeyDescription, user.first_name, user.first_name)));
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ViewGroup parent = (ViewGroup)fragmentView.getParent();
|
|
|
|
if (parent != null) {
|
|
|
|
parent.removeView(fragmentView);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return fragmentView;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onConfigurationChanged(android.content.res.Configuration newConfig) {
|
|
|
|
super.onConfigurationChanged(newConfig);
|
|
|
|
fixLayout();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onResume() {
|
2014-06-04 16:00:42 +00:00
|
|
|
super.onResume();
|
2013-10-25 15:19:00 +00:00
|
|
|
fixLayout();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void fixLayout() {
|
2014-06-03 23:31:48 +00:00
|
|
|
ViewTreeObserver obs = fragmentView.getViewTreeObserver();
|
|
|
|
obs.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
|
|
|
|
@Override
|
|
|
|
public boolean onPreDraw() {
|
2014-06-06 23:35:21 +00:00
|
|
|
if (fragmentView != null) {
|
|
|
|
fragmentView.getViewTreeObserver().removeOnPreDrawListener(this);
|
|
|
|
}
|
|
|
|
if (getParentActivity() == null) {
|
|
|
|
return true;
|
|
|
|
}
|
2014-06-03 23:31:48 +00:00
|
|
|
LinearLayout layout = (LinearLayout)fragmentView;
|
|
|
|
WindowManager manager = (WindowManager)ApplicationLoader.applicationContext.getSystemService(Context.WINDOW_SERVICE);
|
|
|
|
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 15:19:00 +00:00
|
|
|
}
|
|
|
|
|
2014-06-03 23:31:48 +00:00
|
|
|
fragmentView.setPadding(fragmentView.getPaddingLeft(), 0, fragmentView.getPaddingRight(), fragmentView.getPaddingBottom());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
|
|
|
}
|