/* * This part of the Delta Chat fronted is based on Telegram which is covered by the note below. * * This is the source code of Telegram for Android v. 3.x.x. * 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-2016. */ package com.b44t.ui; import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.PackageInfo; import android.content.res.Configuration; import android.os.Build; import android.os.Bundle; import android.view.Gravity; import android.view.View; import android.view.ViewGroup; import android.view.ViewTreeObserver; import android.widget.AdapterView; import android.widget.FrameLayout; import android.widget.LinearLayout; import android.widget.ListView; import com.b44t.messenger.AndroidUtilities; import com.b44t.messenger.MediaController; import com.b44t.messenger.MrMailbox; import com.b44t.messenger.ApplicationLoader; import com.b44t.messenger.LocaleController; import com.b44t.messenger.FileLog; import com.b44t.messenger.MessagesController; import com.b44t.messenger.NotificationCenter; import com.b44t.messenger.R; import com.b44t.ui.ActionBar.BottomSheet; import com.b44t.ui.Adapters.BaseFragmentAdapter; import com.b44t.ui.Cells.CheckBoxCell; import com.b44t.ui.Cells.EmptyCell; import com.b44t.ui.Cells.HeaderCell; import com.b44t.ui.Cells.ShadowSectionCell; import com.b44t.ui.Cells.TextCheckCell; import com.b44t.ui.Cells.TextDetailSettingsCell; import com.b44t.ui.Cells.TextInfoPrivacyCell; import com.b44t.ui.Cells.TextSettingsCell; import com.b44t.ui.ActionBar.ActionBar; import com.b44t.ui.ActionBar.BaseFragment; import com.b44t.ui.Components.LayoutHelper; import com.b44t.ui.Components.NumberPicker; import com.b44t.ui.ActionBar.Theme; import java.util.Locale; public class SettingsActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate /*, PhotoViewer.PhotoViewerProvider -- EDIT BY MR */ { private ListView listView; private ListAdapter listAdapter; private int numberSectionRow; private int numberRow; private int usernameRow; private int settingsSectionRow; private int settingsSectionRow2; private int enableAnimationsRow; private int notificationRow; private int backgroundRow; private int languageRow; private int privacyRow; private int mediaDownloadSection; private int mediaDownloadSection2; private int mobileDownloadRow; private int wifiDownloadRow; private int roamingDownloadRow; private int saveToGalleryRow; private int messagesSectionRow; private int messagesSectionRow2; private int directShareRow; private int textSizeRow; private int stickersRow; private int cacheRow; private int raiseToSpeakRow; private int sendByEnterRow; private int supportSectionRow; private int supportSectionRow2; private int askQuestionRow; private int helpRow; private int privacyPolicyRow; private int sendLogsRow; private int clearLogsRow; private int versionRow; private int contactsSectionRow; private int contactsReimportRow; private int contactsSortRow; private int autoplayGifsRow; private int rowCount; private final static int edit_name = 1; private final static int logout = 2; @Override public boolean onFragmentCreate() { super.onFragmentCreate(); /* EDIT BY MR avatarUpdater.parentFragment = this; avatarUpdater.delegate = new AvatarUpdater.AvatarUpdaterDelegate() { @Override public void didUploadedPhoto(TLRPC.InputFile file, TLRPC.PhotoSize small, TLRPC.PhotoSize big) { TLRPC.TL_photos_uploadProfilePhoto req = new TLRPC.TL_photos_uploadProfilePhoto(); req.caption = ""; req.crop = new TLRPC.TL_inputPhotoCropAuto(); req.file = file; req.geo_point = new TLRPC.TL_inputGeoPointEmpty(); ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() { @Override public void run(TLObject response, TLRPC.TL_error error) { if (error == null) { TLRPC.User user = MessagesController.getInstance().getUser(UserConfig.getClientUserId()); if (user == null) { user = UserConfig.getCurrentUser(); if (user == null) { return; } MessagesController.getInstance().putUser(user, false); } else { UserConfig.setCurrentUser(user); } TLRPC.TL_photos_photo photo = (TLRPC.TL_photos_photo) response; ArrayList sizes = photo.photo.sizes; TLRPC.PhotoSize smallSize = FileLoader.getClosestPhotoSizeWithSize(sizes, 100); TLRPC.PhotoSize bigSize = FileLoader.getClosestPhotoSizeWithSize(sizes, 1000); user.photo = new TLRPC.TL_userProfilePhoto(); user.photo.photo_id = photo.photo.id; if (smallSize != null) { user.photo.photo_small = smallSize.location; } if (bigSize != null) { user.photo.photo_big = bigSize.location; } else if (smallSize != null) { user.photo.photo_small = smallSize.location; } MessagesStorage.getInstance().clearUserPhotos(user.id); ArrayList users = new ArrayList<>(); users.add(user); MessagesStorage.getInstance().putUsersAndChats(users, null, false, true); AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, MessagesController.UPDATE_MASK_ALL); NotificationCenter.getInstance().postNotificationName(NotificationCenter.mainUserInfoChanged); UserConfig.saveConfig(true); } }); } } }); } }; */ NotificationCenter.getInstance().addObserver(this, NotificationCenter.updateInterfaces); rowCount = 0; /* EDIT BY MR overscrollRow = rowCount++; emptyRow = rowCount++; */ numberSectionRow = rowCount++; usernameRow = rowCount++; // EDIT BY MR numberRow = rowCount++; // EDIT BY MR -- these are the account settings settingsSectionRow = rowCount++; settingsSectionRow2 = rowCount++; privacyRow = rowCount++; notificationRow = rowCount++; backgroundRow = rowCount++; enableAnimationsRow = rowCount++; languageRow = rowCount++; mediaDownloadSection = rowCount++; mediaDownloadSection2 = rowCount++; autoplayGifsRow = rowCount++; mobileDownloadRow = -1;//rowCount++; wifiDownloadRow = -1;//rowCount++; roamingDownloadRow = -1;//rowCount++; saveToGalleryRow = -1;//rowCount++; -- for now, we do not use this option, this results in confusing folders ("AppName" and "AppName Images" etc.); instead, for now, the user can use the option to manually save a media cacheRow = rowCount++; messagesSectionRow = rowCount++; messagesSectionRow2 = rowCount++; textSizeRow = rowCount++; // incoming messages stickersRow = -1; // EDIT BY MR --was: rowCount++; if (Build.VERSION.SDK_INT >= 23) { directShareRow = rowCount++; } else { directShareRow = -1; } raiseToSpeakRow = rowCount++; // outgoing message sendByEnterRow = rowCount++; supportSectionRow = rowCount++; supportSectionRow2 = rowCount++; askQuestionRow = -1; // EDIT BY MR -- rowCount++; helpRow = rowCount++; privacyPolicyRow = -1; // EDIT BY MR -- rowCount++; sendLogsRow = -1; // EDIT BY MR clearLogsRow = -1; // EDIT BY MR /* EDIT BY MR if (BuildVars.DEBUG_VERSION) { sendLogsRow = rowCount++; clearLogsRow = rowCount++; } */ versionRow = -1; // EDIT BY MR -- rowCount++; contactsSectionRow = -1; // EDIT BY MR - rowCount++; contactsReimportRow = -1; // EDIT BY MR -rowCount++; contactsSortRow = -1; // EDIT BY MR -- rowCount++; //MessagesController.getInstance().loadFullUser(UserConfig.getCurrentUser(), classGuid, true); return true; } @Override public void onFragmentDestroy() { super.onFragmentDestroy(); /* EDIT BY MR if (avatarImage != null) { avatarImage.setImageDrawable(null); } */ //MessagesController.getInstance().cancelLoadFullUser(UserConfig.getClientUserId()); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.updateInterfaces); /* EDIT BY MR avatarUpdater.clear(); */ } @Override public View createView(Context context) { actionBar.setBackButtonImage(R.drawable.ic_ab_back); /* EDIT BY MR */ actionBar.setAllowOverlayTitle(true); actionBar.setTitle(LocaleController.getString("Settings", R.string.Settings)); /* actionBar.setAddToContainer(false); extraHeight = 88; if (AndroidUtilities.isTablet()) { actionBar.setOccupyStatusBar(false); } /EDIT BY MR */ actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(int id) { if (id == -1) { finishFragment(); } else if (id == edit_name) { /* EDIT BY MR presentFragment(new ChangeNameActivity()); */ } else if (id == logout) { /* EDIT BY MR if (getParentActivity() == null) { return; } AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setMessage(LocaleController.getString("AreYouSureLogout", R.string.AreYouSureLogout)); builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { //MessagesController.getInstance().performLogout(true); // EDIT BY MR } }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); showDialog(builder.create()); */ } } }); /* ActionBarMenu menu = actionBar.createMenu(); ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_other); item.addSubItem(edit_name, LocaleController.getString("EditName", R.string.EditName), 0); item.addSubItem(logout, LocaleController.getString("LogOut", R.string.LogOut), 0); */ listAdapter = new ListAdapter(context); fragmentView = new FrameLayout(context) { /* EDIT BY MR @Override protected boolean drawChild(@NonNull Canvas canvas, @NonNull View child, long drawingTime) { if (child == listView) { boolean result = super.drawChild(canvas, child, drawingTime); if (parentLayout != null) { int actionBarHeight = 0; int childCount = getChildCount(); for (int a = 0; a < childCount; a++) { View view = getChildAt(a); if (view == child) { continue; } if (view instanceof ActionBar && view.getVisibility() == VISIBLE) { if (((ActionBar) view).getCastShadows()) { actionBarHeight = view.getMeasuredHeight(); } break; } } parentLayout.drawHeaderShadow(canvas, actionBarHeight); } return result; } else { return super.drawChild(canvas, child, drawingTime); } } */ }; FrameLayout frameLayout = (FrameLayout) fragmentView; listView = new ListView(context); listView.setDivider(null); listView.setDividerHeight(0); listView.setVerticalScrollBarEnabled(false); AndroidUtilities.setListViewEdgeEffectColor(listView, Theme.ACTION_BAR_COLOR); frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT)); listView.setAdapter(listAdapter); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView adapterView, View view, final int i, long l) { if (i == textSizeRow) { if (getParentActivity() == null) { return; } AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setTitle(LocaleController.getString("TextSize", R.string.TextSize)); final NumberPicker numberPicker = new NumberPicker(getParentActivity()); numberPicker.setMinValue(12); numberPicker.setMaxValue(30); numberPicker.setValue(MessagesController.getInstance().fontSize); builder.setView(numberPicker); builder.setNegativeButton(LocaleController.getString("Done", R.string.Done), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); editor.putInt("fons_size", numberPicker.getValue()); MessagesController.getInstance().fontSize = numberPicker.getValue(); editor.commit(); if (listView != null) { listView.invalidateViews(); } } }); showDialog(builder.create()); } else if (i == enableAnimationsRow) { SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); boolean animations = preferences.getBoolean("view_animations", true); SharedPreferences.Editor editor = preferences.edit(); editor.putBoolean("view_animations", !animations); editor.commit(); if (view instanceof TextCheckCell) { ((TextCheckCell) view).setChecked(!animations); } } else if (i == notificationRow) { presentFragment(new NotificationsSettingsActivity()); } else if (i == backgroundRow) { presentFragment(new WallpapersActivity()); } else if (i == askQuestionRow) { /* EDIT BY MR if (getParentActivity() == null) { return; } final TextView message = new TextView(getParentActivity()); message.setText(Html.fromHtml(LocaleController.getString("AskAQuestionInfo", R.string.AskAQuestionInfo))); message.setTextSize(18); message.setLinkTextColor(Theme.MSG_LINK_TEXT_COLOR); message.setPadding(AndroidUtilities.dp(8), AndroidUtilities.dp(5), AndroidUtilities.dp(8), AndroidUtilities.dp(6)); message.setMovementMethod(new LinkMovementMethodMy()); AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setView(message); builder.setPositiveButton(LocaleController.getString("AskButton", R.string.AskButton), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { performAskAQuestion(); } }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); showDialog(builder.create()); */ } else if (i == sendLogsRow) { /* EDIT BY MR sendLogs(); */ } else if (i == clearLogsRow) { /* EDIT BY MR FileLog.cleanupLogs(); */ } else if (i == sendByEnterRow) { SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); boolean send = preferences.getBoolean("send_by_enter", false); SharedPreferences.Editor editor = preferences.edit(); editor.putBoolean("send_by_enter", !send); editor.commit(); if (view instanceof TextCheckCell) { ((TextCheckCell) view).setChecked(!send); } } else if (i == raiseToSpeakRow) { MediaController.getInstance().toogleRaiseToSpeak(); if (view instanceof TextCheckCell) { ((TextCheckCell) view).setChecked(MediaController.getInstance().canRaiseToSpeak()); } } else if (i == autoplayGifsRow) { MediaController.getInstance().toggleAutoplayGifs(); if (view instanceof TextCheckCell) { ((TextCheckCell) view).setChecked(MediaController.getInstance().canAutoplayGifs()); } } else if (i == saveToGalleryRow) { MediaController.getInstance().toggleSaveToGallery(); if (view instanceof TextCheckCell) { ((TextCheckCell) view).setChecked(MediaController.getInstance().canSaveToGallery()); } } else if(i == directShareRow) { MediaController.getInstance().toggleDirectShare(); if (view instanceof TextCheckCell) { ((TextCheckCell) view).setChecked(MediaController.getInstance().canDirectShare()); } } else if (i == privacyRow) { presentFragment(new PrivacySettingsActivity()); } else if (i == languageRow) { presentFragment(new LanguageSelectActivity()); } else if (i == helpRow) { AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setTitle(LocaleController.getString("AppName", R.string.AppName) + " " + getVersion()); builder.setMessage(MrMailbox.getInfo()); builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { ; } }); showDialog(builder.create()); } else if (i == privacyPolicyRow) { /* EDIT BY MR Browser.openUrl(getParentActivity(), LocaleController.getString("PrivacyPolicyUrl", R.string.PrivacyPolicyUrl)); */ } else if (i == contactsReimportRow) { //not implemented } else if (i == contactsSortRow) { /* if (getParentActivity() == null) { return; } AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setTitle(LocaleController.getString("SortBy", R.string.SortBy)); builder.setItems(new CharSequence[]{ LocaleController.getString("Default", R.string.Default), LocaleController.getString("SortFirstName", R.string.SortFirstName), LocaleController.getString("SortLastName", R.string.SortLastName) }, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); editor.putInt("sortContactsBy", which); editor.commit(); if (listView != null) { listView.invalidateViews(); } } }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); showDialog(builder.create()); */ } else if (i == wifiDownloadRow || i == mobileDownloadRow || i == roamingDownloadRow) { if (getParentActivity() == null) { return; } final boolean maskValues[] = new boolean[6]; BottomSheet.Builder builder = new BottomSheet.Builder(getParentActivity()); int mask = 0; if (i == mobileDownloadRow) { mask = MediaController.getInstance().mobileDataDownloadMask; } else if (i == wifiDownloadRow) { mask = MediaController.getInstance().wifiDownloadMask; } else if (i == roamingDownloadRow) { mask = MediaController.getInstance().roamingDownloadMask; } builder.setApplyTopPadding(false); builder.setApplyBottomPadding(false); LinearLayout linearLayout = new LinearLayout(getParentActivity()); linearLayout.setOrientation(LinearLayout.VERTICAL); for (int a = 0; a < 6; a++) { String name = null; if (a == 0) { maskValues[a] = (mask & MediaController.AUTODOWNLOAD_MASK_PHOTO) != 0; name = LocaleController.getString("AttachPhoto", R.string.AttachPhoto); } else if (a == 1) { maskValues[a] = (mask & MediaController.AUTODOWNLOAD_MASK_AUDIO) != 0; name = LocaleController.getString("AttachAudio", R.string.AttachAudio); } else if (a == 2) { maskValues[a] = (mask & MediaController.AUTODOWNLOAD_MASK_VIDEO) != 0; name = LocaleController.getString("AttachVideo", R.string.AttachVideo); } else if (a == 3) { maskValues[a] = (mask & MediaController.AUTODOWNLOAD_MASK_DOCUMENT) != 0; name = LocaleController.getString("AttachDocument", R.string.AttachDocument); } else if (a == 4) { maskValues[a] = (mask & MediaController.AUTODOWNLOAD_MASK_MUSIC) != 0; name = LocaleController.getString("AttachMusic", R.string.AttachMusic); } else if (a == 5) { maskValues[a] = (mask & MediaController.AUTODOWNLOAD_MASK_GIF) != 0; name = LocaleController.getString("AttachGif", R.string.AttachGif); } CheckBoxCell checkBoxCell = new CheckBoxCell(getParentActivity()); checkBoxCell.setTag(a); checkBoxCell.setBackgroundResource(R.drawable.list_selector); linearLayout.addView(checkBoxCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 48)); checkBoxCell.setText(name, "", maskValues[a], true); checkBoxCell.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { CheckBoxCell cell = (CheckBoxCell) v; int num = (Integer) cell.getTag(); maskValues[num] = !maskValues[num]; cell.setChecked(maskValues[num], true); } }); } BottomSheet.BottomSheetCell cell = new BottomSheet.BottomSheetCell(getParentActivity(), 1); cell.setBackgroundResource(R.drawable.list_selector); cell.setTextAndIcon(LocaleController.getString("Save", R.string.Save).toUpperCase(), 0); cell.setTextColor(Theme.AUTODOWNLOAD_SHEET_SAVE_TEXT_COLOR); cell.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { if (visibleDialog != null) { visibleDialog.dismiss(); } } catch (Exception e) { FileLog.e("messenger", e); } int newMask = 0; for (int a = 0; a < 6; a++) { if (maskValues[a]) { if (a == 0) { newMask |= MediaController.AUTODOWNLOAD_MASK_PHOTO; } else if (a == 1) { newMask |= MediaController.AUTODOWNLOAD_MASK_AUDIO; } else if (a == 2) { newMask |= MediaController.AUTODOWNLOAD_MASK_VIDEO; } else if (a == 3) { newMask |= MediaController.AUTODOWNLOAD_MASK_DOCUMENT; } else if (a == 4) { newMask |= MediaController.AUTODOWNLOAD_MASK_MUSIC; } else if (a == 5) { newMask |= MediaController.AUTODOWNLOAD_MASK_GIF; } } } SharedPreferences.Editor editor = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE).edit(); if (i == mobileDownloadRow) { editor.putInt("mobileDataDownloadMask", newMask); MediaController.getInstance().mobileDataDownloadMask = newMask; } else if (i == wifiDownloadRow) { editor.putInt("wifiDownloadMask", newMask); MediaController.getInstance().wifiDownloadMask = newMask; } else if (i == roamingDownloadRow) { editor.putInt("roamingDownloadMask", newMask); MediaController.getInstance().roamingDownloadMask = newMask; } editor.commit(); if (listView != null) { listView.invalidateViews(); } } }); linearLayout.addView(cell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 48)); builder.setCustomView(linearLayout); showDialog(builder.create()); } else if (i == usernameRow) { presentFragment(new NameSettingsActivity()); } else if (i == numberRow) { presentFragment(new AccountSettingsActivity(null)); } else if (i == stickersRow) { //presentFragment(new StickersActivity()); // EDIT BY MR } else if (i == cacheRow) { presentFragment(new CacheControlActivity()); } } }); listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView parent, View view, int position, long id) { return false; } }); frameLayout.addView(actionBar); /* EDIT BY MR extraHeightView = new View(context); extraHeightView.setPivotY(0); frameLayout.addView(extraHeightView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 88)); shadowView = new View(context); shadowView.setBackgroundResource(R.drawable.header_shadow); frameLayout.addView(shadowView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 3)); avatarImage = new BackupImageView(context); avatarImage.setRoundRadius(AndroidUtilities.dp(21)); avatarImage.setPivotX(0); avatarImage.setPivotY(0); frameLayout.addView(avatarImage, LayoutHelper.createFrame(42, 42, Gravity.TOP | Gravity.LEFT, 64, 0, 0, 0)); avatarImage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { TLRPC.User user = MessagesController.getInstance().getUser(UserConfig.getClientUserId()); if (user != null && user.photo != null && user.photo.photo_big != null) { PhotoViewer.getInstance().setParentActivity(getParentActivity()); PhotoViewer.getInstance().openPhoto(user.photo.photo_big, SettingsActivity.this); } } }); nameTextView = new TextView(context); nameTextView.setTextColor(0xffffffff); nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); nameTextView.setLines(1); nameTextView.setMaxLines(1); nameTextView.setSingleLine(true); nameTextView.setEllipsize(TextUtils.TruncateAt.END); nameTextView.setGravity(Gravity.LEFT); nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); nameTextView.setPivotX(0); nameTextView.setPivotY(0); frameLayout.addView(nameTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 118, 0, 48, 0)); onlineTextView = new TextView(context); onlineTextView.setTextColor(AvatarDrawable.getProfileTextColorForId(5)); onlineTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); onlineTextView.setLines(1); onlineTextView.setMaxLines(1); onlineTextView.setSingleLine(true); onlineTextView.setEllipsize(TextUtils.TruncateAt.END); onlineTextView.setGravity(Gravity.LEFT); frameLayout.addView(onlineTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 118, 0, 48, 0)); writeButton = new ImageView(context); writeButton.setBackgroundResource(R.drawable.floating_user_states); writeButton.setImageResource(R.drawable.floating_camera); writeButton.setScaleType(ImageView.ScaleType.CENTER); if (Build.VERSION.SDK_INT >= 21) { StateListAnimator animator = new StateListAnimator(); animator.addState(new int[]{android.R.attr.state_pressed}, ObjectAnimator.ofFloat(writeButton, "translationZ", AndroidUtilities.dp(2), AndroidUtilities.dp(4)).setDuration(200)); animator.addState(new int[]{}, ObjectAnimator.ofFloat(writeButton, "translationZ", AndroidUtilities.dp(4), AndroidUtilities.dp(2)).setDuration(200)); writeButton.setStateListAnimator(animator); writeButton.setOutlineProvider(new ViewOutlineProvider() { @SuppressLint("NewApi") @Override public void getOutline(View view, Outline outline) { outline.setOval(0, 0, AndroidUtilities.dp(56), AndroidUtilities.dp(56)); } }); } frameLayout.addView(writeButton, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.RIGHT | Gravity.TOP, 0, 0, 16, 0)); writeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (getParentActivity() == null) { return; } AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); CharSequence[] items; TLRPC.User user = MessagesController.getInstance().getUser(UserConfig.getClientUserId()); if (user == null) { user = UserConfig.getCurrentUser(); } if (user == null) { return; } boolean fullMenu = false; if (user.photo != null && user.photo.photo_big != null && !(user.photo instanceof TLRPC.TL_userProfilePhotoEmpty)) { items = new CharSequence[]{LocaleController.getString("FromCamera", R.string.FromCamera), LocaleController.getString("FromGalley", R.string.FromGalley), LocaleController.getString("DeletePhoto", R.string.DeletePhoto)}; fullMenu = true; } else { items = new CharSequence[]{LocaleController.getString("FromCamera", R.string.FromCamera), LocaleController.getString("FromGalley", R.string.FromGalley)}; } final boolean full = fullMenu; builder.setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { if (i == 0) { avatarUpdater.openCamera(); } else if (i == 1) { avatarUpdater.openGallery(); } else if (i == 2) { MessagesController.getInstance().deleteUserPhoto(null); } } }); showDialog(builder.create()); } }); */ needLayout(); /* EDIT BY MR listView.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (totalItemCount == 0) { return; } int height = 0; View child = view.getChildAt(0); if (child != null) { if (firstVisibleItem == 0) { height = AndroidUtilities.dp(88) + (child.getTop() < 0 ? child.getTop() : 0); } if (extraHeight != height) { extraHeight = height; needLayout(); } } } }); */ return fragmentView; } // EDIT BY MR private String getVersion() { try { PackageInfo pInfo = ApplicationLoader.applicationContext.getPackageManager().getPackageInfo(ApplicationLoader.applicationContext.getPackageName(), 0); int code = pInfo.versionCode / 10; String abi = ""; switch (pInfo.versionCode % 10) { case 0: abi = "arm"; break; case 1: abi = "arm-v7a"; break; case 2: abi = "x86"; break; case 3: abi = "universal"; break; } return String.format(Locale.US, "V%s-%s", pInfo.versionName, abi); } catch (Exception e) { return "ErrVersion"; } } // /EDIT BY MR @Override protected void onDialogDismiss(Dialog dialog) { MediaController.getInstance().checkAutodownloadSettings(); } /* EDIT BY MR -- unneeded implementation of PhotoViewer.PhotoViewerProvider @Override public void updatePhotoAtIndex(int index) { } @Override public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) { if (fileLocation == null) { return null; } TLRPC.User user = MessagesController.getInstance().getUser(UserConfig.getClientUserId()); if (user != null && user.photo != null && user.photo.photo_big != null) { TLRPC.FileLocation photoBig = user.photo.photo_big; if (photoBig.local_id == fileLocation.local_id && photoBig.volume_id == fileLocation.volume_id && photoBig.dc_id == fileLocation.dc_id) { int coords[] = new int[2]; avatarImage.getLocationInWindow(coords); PhotoViewer.PlaceProviderObject object = new PhotoViewer.PlaceProviderObject(); object.viewX = coords[0]; object.viewY = coords[1] - AndroidUtilities.statusBarHeight; object.parentView = avatarImage; object.imageReceiver = avatarImage.getImageReceiver(); object.dialogId = UserConfig.getClientUserId(); object.thumb = object.imageReceiver.getBitmap(); object.size = -1; object.radius = avatarImage.getImageReceiver().getRoundRadius(); object.scale = avatarImage.getScaleX(); return object; } } return null; } @Override public Bitmap getThumbForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) { return null; } @Override public void willSwitchFromPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) { } @Override public void willHidePhotoViewer() { avatarImage.getImageReceiver().setVisible(true, true); } @Override public boolean isPhotoChecked(int index) { return false; } @Override public void setPhotoChecked(int index) { } @Override public boolean cancelButtonPressed() { return true; } @Override public void sendButtonPressed(int index) { } @Override public int getSelectedCount() { return 0; } */ /* EDIT BY MR private void performAskAQuestion() { final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); int uid = preferences.getInt("support_id", 0); TLRPC.User supportUser = null; if (uid != 0) { supportUser = MessagesController.getInstance().getUser(uid); if (supportUser == null) { String userString = preferences.getString("support_user", null); if (userString != null) { try { byte[] datacentersBytes = Base64.decode(userString, Base64.DEFAULT); if (datacentersBytes != null) { SerializedData data = new SerializedData(datacentersBytes); supportUser = TLRPC.User.TLdeserialize(data, data.readInt32(false), false); if (supportUser != null && supportUser.id == 333000) { supportUser = null; } data.cleanup(); } } catch (Exception e) { FileLog.e("messenger", e); supportUser = null; } } } } if (supportUser == null) { final ProgressDialog progressDialog = new ProgressDialog(getParentActivity()); progressDialog.setMessage(LocaleController.getString("Loading", R.string.Loading)); progressDialog.setCanceledOnTouchOutside(false); progressDialog.setCancelable(false); progressDialog.show(); TLRPC.TL_help_getSupport req = new TLRPC.TL_help_getSupport(); ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() { @Override public void run(TLObject response, TLRPC.TL_error error) { if (error == null) { final TLRPC.TL_help_support res = (TLRPC.TL_help_support) response; AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { SharedPreferences.Editor editor = preferences.edit(); editor.putInt("support_id", res.user.id); SerializedData data = new SerializedData(); res.user.serializeToStream(data); editor.putString("support_user", Base64.encodeToString(data.toByteArray(), Base64.DEFAULT)); editor.commit(); data.cleanup(); try { progressDialog.dismiss(); } catch (Exception e) { FileLog.e("messenger", e); } ArrayList users = new ArrayList<>(); users.add(res.user); MessagesStorage.getInstance().putUsersAndChats(users, null, true, true); MessagesController.getInstance().putUser(res.user, false); Bundle args = new Bundle(); args.putInt("user_id", res.user.id); presentFragment(new ChatActivity(args)); } }); } else { AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { try { progressDialog.dismiss(); } catch (Exception e) { FileLog.e("messenger", e); } } }); } } }); } else { MessagesController.getInstance().putUser(supportUser, true); Bundle args = new Bundle(); args.putInt("user_id", supportUser.id); presentFragment(new ChatActivity(args)); } } */ @Override public void onActivityResultFragment(int requestCode, int resultCode, Intent data) { //avatarUpdater.onActivityResult(requestCode, resultCode, data); -- EDIT BY MR } @Override public void saveSelfArgs(Bundle args) { /* EDIT BY MR if (avatarUpdater != null && avatarUpdater.currentPicturePath != null) { args.putString("path", avatarUpdater.currentPicturePath); } */ } @Override public void restoreSelfArgs(Bundle args) { /* EDIT BY MR if (avatarUpdater != null) { avatarUpdater.currentPicturePath = args.getString("path"); } */ } @Override public void didReceivedNotification(int id, Object... args) { if (id == NotificationCenter.updateInterfaces) { int mask = (Integer) args[0]; if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0) { updateUserData(); } } } @Override public void onResume() { super.onResume(); if (listAdapter != null) { listAdapter.notifyDataSetChanged(); } updateUserData(); fixLayout(); } @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); fixLayout(); } private void needLayout() { /* EDIT BY MR FrameLayout.LayoutParams layoutParams; int newTop = (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0) + ActionBar.getCurrentActionBarHeight(); if (listView != null) { layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams(); if (layoutParams.topMargin != newTop) { layoutParams.topMargin = newTop; listView.setLayoutParams(layoutParams); extraHeightView.setTranslationY(newTop); } } if (avatarImage != null) { float diff = extraHeight / (float) AndroidUtilities.dp(88); extraHeightView.setScaleY(diff); shadowView.setTranslationY(newTop + extraHeight); writeButton.setTranslationY((actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0) + ActionBar.getCurrentActionBarHeight() + extraHeight - AndroidUtilities.dp(29.5f)); final boolean setVisible = diff > 0.2f; boolean currentVisible = writeButton.getTag() == null; if (setVisible != currentVisible) { if (setVisible) { writeButton.setTag(null); writeButton.setVisibility(View.VISIBLE); } else { writeButton.setTag(0); } if (writeButtonAnimation != null) { AnimatorSet old = writeButtonAnimation; writeButtonAnimation = null; old.cancel(); } writeButtonAnimation = new AnimatorSet(); if (setVisible) { writeButtonAnimation.setInterpolator(new DecelerateInterpolator()); writeButtonAnimation.playTogether( ObjectAnimator.ofFloat(writeButton, "scaleX", 1.0f), ObjectAnimator.ofFloat(writeButton, "scaleY", 1.0f), ObjectAnimator.ofFloat(writeButton, "alpha", 1.0f) ); } else { writeButtonAnimation.setInterpolator(new AccelerateInterpolator()); writeButtonAnimation.playTogether( ObjectAnimator.ofFloat(writeButton, "scaleX", 0.2f), ObjectAnimator.ofFloat(writeButton, "scaleY", 0.2f), ObjectAnimator.ofFloat(writeButton, "alpha", 0.0f) ); } writeButtonAnimation.setDuration(150); writeButtonAnimation.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Animator animation) { if (writeButtonAnimation != null && writeButtonAnimation.equals(animation)) { writeButton.setVisibility(setVisible ? View.VISIBLE : View.GONE); writeButtonAnimation = null; } } }); writeButtonAnimation.start(); } avatarImage.setScaleX((42 + 18 * diff) / 42.0f); avatarImage.setScaleY((42 + 18 * diff) / 42.0f); float avatarY = (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0) + ActionBar.getCurrentActionBarHeight() / 2.0f * (1.0f + diff) - 21 * AndroidUtilities.density + 27 * AndroidUtilities.density * diff; avatarImage.setTranslationX(-AndroidUtilities.dp(47) * diff); avatarImage.setTranslationY((float) Math.ceil(avatarY)); nameTextView.setTranslationX(-21 * AndroidUtilities.density * diff); nameTextView.setTranslationY((float) Math.floor(avatarY) - (float) Math.ceil(AndroidUtilities.density) + (float) Math.floor(7 * AndroidUtilities.density * diff)); onlineTextView.setTranslationX(-21 * AndroidUtilities.density * diff); onlineTextView.setTranslationY((float) Math.floor(avatarY) + AndroidUtilities.dp(22) + (float )Math.floor(11 * AndroidUtilities.density) * diff); nameTextView.setScaleX(1.0f + 0.12f * diff); nameTextView.setScaleY(1.0f + 0.12f * diff); } */ } private void fixLayout() { if (fragmentView == null) { return; } fragmentView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { if (fragmentView != null) { needLayout(); fragmentView.getViewTreeObserver().removeOnPreDrawListener(this); } return true; } }); } private void updateUserData() { } /* EDIT BY MR private void sendLogs() { try { ArrayList uris = new ArrayList<>(); File sdCard = ApplicationLoader.applicationContext.getExternalFilesDir(null); File dir = new File(sdCard.getAbsolutePath() + "/logs"); File[] files = dir.listFiles(); for (File file : files) { uris.add(Uri.fromFile(file)); } if (uris.isEmpty()) { return; } Intent i = new Intent(Intent.ACTION_SEND_MULTIPLE); i.setType("message/rfc822") ; i.putExtra(Intent.EXTRA_EMAIL, ""); i.putExtra(Intent.EXTRA_SUBJECT, "last logs"); i.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); getParentActivity().startActivityForResult(Intent.createChooser(i, "Select email application."), 500); } catch (Exception e) { e.printStackTrace(); } } */ private class ListAdapter extends BaseFragmentAdapter { private Context mContext; public ListAdapter(Context context) { mContext = context; } @Override public boolean areAllItemsEnabled() { return false; } @Override public boolean isEnabled(int i) { return i == textSizeRow || i == enableAnimationsRow || i == notificationRow || i == backgroundRow || i == numberRow || i == askQuestionRow || i == sendLogsRow || i == sendByEnterRow || i == autoplayGifsRow || i == privacyRow || i == wifiDownloadRow || i == mobileDownloadRow || i == clearLogsRow || i == roamingDownloadRow || i == languageRow || i == usernameRow || i == helpRow || i == contactsSortRow || i == contactsReimportRow || i == saveToGalleryRow || i == stickersRow || i == cacheRow || i == raiseToSpeakRow || i == privacyPolicyRow || i == directShareRow || i == versionRow; } @Override public int getCount() { return rowCount; } @Override public Object getItem(int i) { return null; } @Override public long getItemId(int i) { return i; } @Override public boolean hasStableIds() { return false; } @Override public View getView(int i, View view, ViewGroup viewGroup) { int type = getItemViewType(i); if (type == 0) { if (view == null) { view = new EmptyCell(mContext); } /* EDIT BY MR if (i == overscrollRow) { ((EmptyCell) view).setHeight(AndroidUtilities.dp(88)); } else */ { ((EmptyCell) view).setHeight(AndroidUtilities.dp(16)); } } else if (type == 1) { if (view == null) { view = new ShadowSectionCell(mContext); } } else if (type == 2) { if (view == null) { view = new TextSettingsCell(mContext); } TextSettingsCell textCell = (TextSettingsCell) view; if (i == textSizeRow) { SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); int size = preferences.getInt("fons_size", AndroidUtilities.isTablet() ? 18 : 16); textCell.setTextAndValue(LocaleController.getString("TextSize", R.string.TextSize), String.format("%d", size), true); } else if (i == languageRow) { textCell.setTextAndValue(LocaleController.getString("Language", R.string.Language), LocaleController.getCurrentLanguageName(), false); } else if (i == contactsSortRow) { /* EDIT BY MR String value; SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); int sort = preferences.getInt("sortContactsBy", 0); if (sort == 0) { value = LocaleController.getString("Default", R.string.Default); } else if (sort == 1) { value = LocaleController.getString("FirstName", R.string.SortFirstName); } else { value = LocaleController.getString("LastName", R.string.SortLastName); } textCell.setTextAndValue(LocaleController.getString("SortBy", R.string.SortBy), value, true); */ } else if (i == notificationRow) { textCell.setText(LocaleController.getString("NotificationsAndSounds", R.string.NotificationsAndSounds), true); } else if (i == backgroundRow) { textCell.setText(LocaleController.getString("ChatBackground", R.string.ChatBackground), true); } else if (i == sendLogsRow) { textCell.setText("Send Logs", true); } else if (i == clearLogsRow) { textCell.setText("Clear Logs", true); } /* EDIT BY MR else if (i == askQuestionRow) { textCell.setText(LocaleController.getString("AskAQuestion", R.string.AskAQuestion), true); } EDIT BY MR*/ else if (i == privacyRow) { textCell.setText(LocaleController.getString("PrivacySettings", R.string.PrivacySettings), true); } else if (i == helpRow) { textCell.setText(LocaleController.getString("AboutThisProgram", R.string.AboutThisProgram), true); } else if (i == contactsReimportRow) { textCell.setText(LocaleController.getString("ImportContacts", R.string.ImportContacts), true); } else if (i == stickersRow) { textCell.setText(LocaleController.getString("Stickers", R.string.Stickers), true); } else if (i == cacheRow) { textCell.setText(LocaleController.getString("CacheSettings", R.string.CacheSettings), true); } /* EDIT BY MR else if (i == privacyPolicyRow) { textCell.setText(LocaleController.getString("PrivacyPolicy", R.string.PrivacyPolicy), true); } EDIT BY MR*/ } else if (type == 3) { if (view == null) { view = new TextCheckCell(mContext); } TextCheckCell textCell = (TextCheckCell) view; SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); if (i == enableAnimationsRow) { textCell.setTextAndCheck(LocaleController.getString("EnableAnimations", R.string.EnableAnimations), preferences.getBoolean("view_animations", true), true); } else if (i == sendByEnterRow) { textCell.setTextAndCheck(LocaleController.getString("SendByEnter", R.string.SendByEnter), preferences.getBoolean("send_by_enter", false), false); } else if (i == saveToGalleryRow) { textCell.setTextAndCheck(LocaleController.getString("SaveToGallerySettings", R.string.SaveToGallerySettings), MediaController.getInstance().canSaveToGallery(), true); } else if (i == autoplayGifsRow) { textCell.setTextAndCheck(LocaleController.getString("AutoplayGifs", R.string.AutoplayGifs), MediaController.getInstance().canAutoplayGifs(), true); } else if (i == raiseToSpeakRow) { textCell.setTextAndCheck(LocaleController.getString("RaiseToSpeak", R.string.RaiseToSpeak), MediaController.getInstance().canRaiseToSpeak(), true); } else if (i == directShareRow) { textCell.setTextAndValueAndCheck(LocaleController.getString("DirectShare", R.string.DirectShare), LocaleController.getString("DirectShareInfo", R.string.DirectShareInfo), MediaController.getInstance().canDirectShare(), false, true); } } else if (type == 4) { if (view == null) { view = new HeaderCell(mContext); } if (i == settingsSectionRow2) { ((HeaderCell) view).setText(LocaleController.getString("SETTINGS", R.string.SETTINGS)); } else if (i == supportSectionRow2) { ((HeaderCell) view).setText(LocaleController.getString("Info", R.string.Info)); // EDIT BY MR -- was: Support } else if (i == messagesSectionRow2) { ((HeaderCell) view).setText(LocaleController.getString("MessagesSettings", R.string.MessagesSettings)); } else if (i == mediaDownloadSection2) { ((HeaderCell) view).setText(LocaleController.getString("Media", R.string.Media)); } else if (i == numberSectionRow) { ((HeaderCell) view).setText(LocaleController.getString("MyAccount", R.string.MyAccount)); // EDIT BY MR } } else if (type == 5) { if (view == null) { view = new TextInfoPrivacyCell(mContext); /* EDIT BY MR try { PackageInfo pInfo = ApplicationLoader.applicationContext.getPackageManager().getPackageInfo(ApplicationLoader.applicationContext.getPackageName(), 0); int code = pInfo.versionCode / 10; String abi = ""; switch (pInfo.versionCode % 10) { case 0: abi = "arm"; break; case 1: abi = "arm-v7a"; break; case 2: abi = "x86"; break; case 3: abi = "universal"; break; } ((TextInfoCell) view).setText(String.format(Locale.US, "Telegram for Android v%s (%d) %s", pInfo.versionName, code, abi)); } catch (Exception e) { FileLog.e("messenger", e); } */ } } else if (type == 6) { if (view == null) { view = new TextDetailSettingsCell(mContext); } TextDetailSettingsCell textCell = (TextDetailSettingsCell) view; if (i == mobileDownloadRow || i == wifiDownloadRow || i == roamingDownloadRow) { int mask; String value; SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); if (i == mobileDownloadRow) { value = LocaleController.getString("WhenUsingMobileData", R.string.WhenUsingMobileData); mask = MediaController.getInstance().mobileDataDownloadMask; } else if (i == wifiDownloadRow) { value = LocaleController.getString("WhenConnectedOnWiFi", R.string.WhenConnectedOnWiFi); mask = MediaController.getInstance().wifiDownloadMask; } else { value = LocaleController.getString("WhenRoaming", R.string.WhenRoaming); mask = MediaController.getInstance().roamingDownloadMask; } String text = ""; if ((mask & MediaController.AUTODOWNLOAD_MASK_PHOTO) != 0) { text += LocaleController.getString("AttachPhoto", R.string.AttachPhoto); } if ((mask & MediaController.AUTODOWNLOAD_MASK_AUDIO) != 0) { if (text.length() != 0) { text += ", "; } text += LocaleController.getString("AttachAudio", R.string.AttachAudio); } if ((mask & MediaController.AUTODOWNLOAD_MASK_VIDEO) != 0) { if (text.length() != 0) { text += ", "; } text += LocaleController.getString("AttachVideo", R.string.AttachVideo); } if ((mask & MediaController.AUTODOWNLOAD_MASK_DOCUMENT) != 0) { if (text.length() != 0) { text += ", "; } text += LocaleController.getString("AttachDocument", R.string.AttachDocument); } if ((mask & MediaController.AUTODOWNLOAD_MASK_MUSIC) != 0) { if (text.length() != 0) { text += ", "; } text += LocaleController.getString("AttachMusic", R.string.AttachMusic); } if ((mask & MediaController.AUTODOWNLOAD_MASK_GIF) != 0) { if (text.length() != 0) { text += ", "; } text += LocaleController.getString("AttachGif", R.string.AttachGif); } if (text.length() == 0) { text = LocaleController.getString("NoMediaAutoDownload", R.string.NoMediaAutoDownload); } textCell.setTextAndValue(value, text, true); } else if (i == numberRow) { /* EDIT BY MR TLRPC.User user = UserConfig.getCurrentUser(); String value; if (user != null && user.phone != null && user.phone.length() != 0) { value = PhoneFormat.getInstance().format("+" + user.phone); } else { value = LocaleController.getString("NumberUnknown", R.string.NumberUnknown); } textCell.setTextAndValue(value, LocaleController.getString("Phone", R.string.Phone), true); */ // EDIT BY MR String subtitle; if( MrMailbox.isConfigured()!=0) { subtitle = MrMailbox.getConfig("addr", ""); } else { subtitle = LocaleController.getString("AccountNotConfigured", R.string.AccountNotConfigured); } textCell.setTextAndValue(LocaleController.getString("AccountSettings", R.string.AccountSettings), subtitle, false); // /EDIT BY MR } else if (i == usernameRow) { /* EDIT BY MR TLRPC.User user = UserConfig.getCurrentUser(); String value; if (user != null && user.username != null && user.username.length() != 0) { value = "@" + user.username; } else { value = LocaleController.getString("UsernameEmpty", R.string.UsernameEmpty); } textCell.setTextAndValue("foo", LocaleController.getString("Username", R.string.Username), false); */ // EDIT BY MR String subtitle = MrMailbox.getConfig("displayname", ""); if( subtitle.isEmpty()) { subtitle = LocaleController.getString("NotSet", R.string.NotSet); } textCell.setTextAndValue(LocaleController.getString("MyName", R.string.MyName), subtitle, true); // /EDIT BY MR } } return view; } @Override public int getItemViewType(int i) { /* EDIT BY MR if (i == emptyRow || i == overscrollRow) { return 0; } */ if (i == settingsSectionRow || i == supportSectionRow || i == messagesSectionRow || i == mediaDownloadSection || i == contactsSectionRow) { return 1; } else if (i == enableAnimationsRow || i == sendByEnterRow || i == saveToGalleryRow || i == autoplayGifsRow || i == raiseToSpeakRow || i == directShareRow) { return 3; } else if (i == notificationRow || i == backgroundRow || i == askQuestionRow || i == sendLogsRow || i == privacyRow || i == clearLogsRow || i == helpRow || i == contactsReimportRow || i == textSizeRow || i == languageRow || i == contactsSortRow || i == stickersRow || i == cacheRow || i == privacyPolicyRow) { return 2; } else if (i == versionRow) { return 5; } else if (i == wifiDownloadRow || i == mobileDownloadRow || i == roamingDownloadRow || i == numberRow || i == usernameRow) { return 6; } else if (i == settingsSectionRow2 || i == messagesSectionRow2 || i == supportSectionRow2 || i == numberSectionRow || i == mediaDownloadSection2) { return 4; } else { return 2; } } @Override public int getViewTypeCount() { return 7; } @Override public boolean isEmpty() { return false; } } }