正在查看: Plus 12 v10.13.1.1 应用的 ThemingContactsActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Plus 12 v10.13.1.1 应用的 ThemingContactsActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package org.telegram.ui;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.Toast;
import java.util.ArrayList;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.R;
import org.telegram.ui.ActionBar.AlertDialog;
import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.ActionBar.INavigationLayout;
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.Cells.HeaderCell;
import org.telegram.ui.Cells.ShadowSectionCell;
import org.telegram.ui.Cells.TextCheckCell;
import org.telegram.ui.Cells.TextColorCell;
import org.telegram.ui.Cells.TextDetailSettingsCell;
import org.telegram.ui.Cells.TextSettingsCell;
public class ThemingContactsActivity extends BaseFragment {
public int avatarRadiusRow;
public int headerColorRow;
public int headerGradientColorRow;
public int headerGradientRow;
public int headerIconsColorRow;
public int headerSection2Row;
public int headerTitleColorRow;
public int iconsColorRow;
public ListAdapter listAdapter;
public ListView listView;
public int nameColorRow;
public int nameSizeRow;
public int onlineColorRow;
public int rowColorRow;
public int rowCount;
public int rowGradientColorRow;
public int rowGradientListCheckRow;
public int rowGradientRow;
public int rowsSection2Row;
public int rowsSectionRow;
public int scrollToPosition;
public boolean showPrefix;
public int statusColorRow;
public int statusSizeRow;
public ThemingContactsActivity() {
}
public ThemingContactsActivity(Bundle args) {
super(args);
}
public boolean onFragmentCreate() {
super.onFragmentCreate();
this.rowCount = 0;
int i = 0 + 1;
this.rowCount = i;
this.headerSection2Row = 0;
int i2 = i + 1;
this.rowCount = i2;
this.headerColorRow = i;
int i3 = i2 + 1;
this.rowCount = i3;
this.headerGradientRow = i2;
int i4 = i3 + 1;
this.rowCount = i4;
this.headerGradientColorRow = i3;
int i5 = i4 + 1;
this.rowCount = i5;
this.headerTitleColorRow = i4;
int i6 = i5 + 1;
this.rowCount = i6;
this.headerIconsColorRow = i5;
int i7 = i6 + 1;
this.rowCount = i7;
this.rowsSectionRow = i6;
int i8 = i7 + 1;
this.rowCount = i8;
this.rowsSection2Row = i7;
int i9 = i8 + 1;
this.rowCount = i9;
this.rowColorRow = i8;
int i10 = i9 + 1;
this.rowCount = i10;
this.rowGradientRow = i9;
int i11 = i10 + 1;
this.rowCount = i11;
this.rowGradientColorRow = i10;
int i12 = i11 + 1;
this.rowCount = i12;
this.avatarRadiusRow = i11;
int i13 = i12 + 1;
this.rowCount = i13;
this.iconsColorRow = i12;
int i14 = i13 + 1;
this.rowCount = i14;
this.nameColorRow = i13;
int i15 = i14 + 1;
this.rowCount = i15;
this.nameSizeRow = i14;
int i16 = i15 + 1;
this.rowCount = i16;
this.statusColorRow = i15;
int i17 = i16 + 1;
this.rowCount = i17;
this.statusSizeRow = i16;
this.rowCount = i17 + 1;
this.onlineColorRow = i17;
this.showPrefix = ApplicationLoader.applicationContext.getSharedPreferences("plusconfig", 0).getBoolean("contactsShowPrefix", true);
Bundle bundle = ((BaseFragment) this).arguments;
if (bundle != null) {
this.scrollToPosition = bundle.getInt("scroll_to_position", 0);
}
return true;
}
public void onFragmentDestroy() {
super.onFragmentDestroy();
}
public final void clickItem(final int position) {
try {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ThemingContactsActivity.this.lambda$clickItem$1(position);
}
}, 300L);
} catch (Exception e) {
FileLog.e(e);
}
}
public void lambda$clickItem$1(int i) {
ListView listView = this.listView;
listView.performItemClick(listView, i, listView.getItemIdAtPosition(i));
View viewByPosition = getViewByPosition(i);
if (viewByPosition == null || !(viewByPosition instanceof TextCheckCell)) {
return;
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ThemingContactsActivity.this.lambda$clickItem$0();
}
}, 200L);
}
public void lambda$clickItem$0() {
this.listAdapter.notifyDataSetChanged();
}
public final View getViewByPosition(int pos) {
int firstVisiblePosition = this.listView.getFirstVisiblePosition();
int childCount = (this.listView.getChildCount() + firstVisiblePosition) - 1;
if (pos < firstVisiblePosition || pos > childCount) {
return this.listView.getAdapter().getView(pos, null, this.listView);
}
return this.listView.getChildAt(pos - firstVisiblePosition);
}
public android.view.View createView(android.content.Context r5) {
throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ThemingContactsActivity.createView(android.content.Context):android.view.View");
}
public class AnonymousClass4 implements AdapterView.OnItemLongClickListener {
public AnonymousClass4() {
}
@Override
public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {
if (ThemingContactsActivity.this.getParentActivity() == null) {
return false;
}
final String obj = view.getTag() != null ? view.getTag().toString() : "";
AlertDialog.Builder builder = new AlertDialog.Builder(ThemingContactsActivity.this.getParentActivity());
ArrayList arrayList = new ArrayList();
final ArrayList arrayList2 = new ArrayList();
if (obj != null && !obj.isEmpty()) {
builder.setTitle(obj);
}
arrayList.add(LocaleController.getString("CopyLink", R.string.CopyLink));
arrayList2.add(0);
arrayList.add(LocaleController.getString("ShareLink", R.string.ShareLink));
arrayList2.add(2);
arrayList.add(LocaleController.getString("Reset", R.string.Reset));
arrayList2.add(1);
final String prefix = ThemingContactsActivity.this.getPrefix(i);
builder.setItems((CharSequence[]) arrayList.toArray(new CharSequence[arrayList.size()]), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i2) {
int intValue = ((Integer) arrayList2.get(i2)).intValue();
final String format = String.format("https://t.me/thememods/%s", prefix);
if (intValue == 0) {
try {
((ClipboardManager) ApplicationLoader.applicationContext.getSystemService("clipboard")).setPrimaryClip(ClipData.newPlainText("label", format));
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
if (ThemingContactsActivity.this.getParentActivity() != null) {
Toast.makeText(ThemingContactsActivity.this.getParentActivity(), format, 0).show();
}
}
});
return;
} catch (Exception e) {
FileLog.e(e);
return;
}
}
if (intValue == 1) {
ThemingContactsActivity.this.resetPref(obj);
return;
}
if (intValue == 2) {
try {
Intent intent = new Intent("android.intent.action.SEND");
intent.setType("text/plain");
intent.putExtra("android.intent.extra.TEXT", format);
ThemingContactsActivity.this.getParentActivity().startActivityForResult(Intent.createChooser(intent, LocaleController.getString("ShareLink", R.string.ShareLink)), 500);
} catch (Exception e2) {
FileLog.e(e2);
}
}
}
});
ThemingContactsActivity.this.showDialog(builder.create());
return true;
}
}
public final void resetPref(String key) {
SharedPreferences.Editor edit = ApplicationLoader.applicationContext.getSharedPreferences("theme", 0).edit();
if (key != null) {
edit.remove(key);
}
edit.commit();
Theme.updateContactsColors();
ListView listView = this.listView;
if (listView != null) {
listView.invalidateViews();
}
refreshTheme();
}
public final void commitInt(String key, int value) {
SharedPreferences.Editor edit = ApplicationLoader.applicationContext.getSharedPreferences("theme", 0).edit();
edit.putInt(key, value);
edit.commit();
ListView listView = this.listView;
if (listView != null) {
listView.invalidateViews();
}
refreshTheme();
}
public final void refreshTheme() {
Theme.applyPlusTheme();
INavigationLayout iNavigationLayout = ((BaseFragment) this).parentLayout;
if (iNavigationLayout != null) {
iNavigationLayout.rebuildAllFragmentViews(false, false);
}
}
public void onResume() {
super.onResume();
ListAdapter listAdapter = this.listAdapter;
if (listAdapter != null) {
listAdapter.notifyDataSetChanged();
}
fixLayout();
}
public final void updateTheme() {
((BaseFragment) this).actionBar.setBackgroundColor(Theme.prefActionbarColor);
((BaseFragment) this).actionBar.setTitleColor(Theme.prefActionbarTitleColor);
Drawable drawable = getParentActivity().getResources().getDrawable(R.drawable.ic_ab_back);
drawable.setColorFilter(Theme.prefActionbarIconsColor, PorterDuff.Mode.MULTIPLY);
((BaseFragment) this).actionBar.setBackButtonDrawable(drawable);
((BaseFragment) this).actionBar.setItemsColor(Theme.prefActionbarIconsColor, false);
}
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
fixLayout();
}
public final void fixLayout() {
View view = ((BaseFragment) this).fragmentView;
if (view == null) {
return;
}
view.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
View view2 = ((BaseFragment) ThemingContactsActivity.this).fragmentView;
if (view2 == null) {
return false;
}
view2.getViewTreeObserver().removeOnPreDrawListener(this);
return false;
}
});
}
public final String getPrefix(int i) {
if (i == this.headerSection2Row) {
return "3.1 ";
}
int i2 = this.rowsSection2Row;
if (i == i2) {
return "3.2 ";
}
if (i < i2) {
return "3.1." + i + " ";
}
return "3.2." + (i - this.rowsSection2Row) + " ";
}
public class ListAdapter extends BaseAdapter {
public Context mContext;
@Override
public boolean areAllItemsEnabled() {
return false;
}
@Override
public Object getItem(int i) {
return null;
}
@Override
public long getItemId(int i) {
return i;
}
@Override
public int getViewTypeCount() {
return 6;
}
@Override
public boolean hasStableIds() {
return false;
}
@Override
public boolean isEmpty() {
return false;
}
public ListAdapter(Context context) {
this.mContext = context;
}
@Override
public boolean isEnabled(int i) {
int intDef = AndroidUtilities.getIntDef("contactsRowGradient", 0);
return i == ThemingContactsActivity.this.headerColorRow || i == ThemingContactsActivity.this.headerGradientRow || (AndroidUtilities.getIntDef("contactsHeaderGradient", 0) != 0 && i == ThemingContactsActivity.this.headerGradientColorRow) || i == ThemingContactsActivity.this.headerTitleColorRow || i == ThemingContactsActivity.this.headerIconsColorRow || i == ThemingContactsActivity.this.iconsColorRow || i == ThemingContactsActivity.this.rowColorRow || i == ThemingContactsActivity.this.rowGradientRow || ((intDef != 0 && i == ThemingContactsActivity.this.rowGradientColorRow) || ((intDef != 0 && i == ThemingContactsActivity.this.rowGradientListCheckRow) || i == ThemingContactsActivity.this.avatarRadiusRow || i == ThemingContactsActivity.this.nameColorRow || i == ThemingContactsActivity.this.nameSizeRow || i == ThemingContactsActivity.this.statusColorRow || i == ThemingContactsActivity.this.statusSizeRow || i == ThemingContactsActivity.this.onlineColorRow));
}
@Override
public int getCount() {
return ThemingContactsActivity.this.rowCount;
}
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
View textDetailSettingsCell;
int itemViewType = getItemViewType(i);
String prefix = ThemingContactsActivity.this.showPrefix ? ThemingContactsActivity.this.getPrefix(i) : "";
SharedPreferences sharedPreferences = ApplicationLoader.applicationContext.getSharedPreferences("theme", 0);
if (itemViewType == 0) {
if (view == null) {
textDetailSettingsCell = new ShadowSectionCell(this.mContext);
}
textDetailSettingsCell = view;
} else if (itemViewType == 1) {
if (view == null) {
textDetailSettingsCell = new HeaderCell(this.mContext);
textDetailSettingsCell.setBackgroundColor(-1);
} else {
textDetailSettingsCell = view;
}
if (i == ThemingContactsActivity.this.headerSection2Row) {
((HeaderCell) textDetailSettingsCell).setText(prefix + LocaleController.getString("Header", R.string.Header));
} else if (i == ThemingContactsActivity.this.rowsSection2Row) {
((HeaderCell) textDetailSettingsCell).setText(prefix + LocaleController.getString("ContactsList", R.string.ContactsList));
}
} else if (itemViewType == 2) {
textDetailSettingsCell = view == null ? new TextSettingsCell(this.mContext) : view;
TextSettingsCell textSettingsCell = (TextSettingsCell) textDetailSettingsCell;
textSettingsCell.setMultilineText();
if (i == ThemingContactsActivity.this.avatarRadiusRow) {
textSettingsCell.setTag("contactsAvatarRadius");
textSettingsCell.setTextAndValue(prefix + LocaleController.getString("AvatarRadius", R.string.AvatarRadius), String.format("%d", Integer.valueOf(Theme.contactsAvatarRadius)), true);
} else if (i == ThemingContactsActivity.this.nameSizeRow) {
textSettingsCell.setTag("contactsNameSize");
textSettingsCell.setTextAndValue(prefix + LocaleController.getString("NameSize", R.string.NameSize), String.format("%d", Integer.valueOf(Theme.contactsNameSize)), true);
} else if (i == ThemingContactsActivity.this.statusSizeRow) {
textSettingsCell.setTag("contactsStatusSize");
textSettingsCell.setTextAndValue(prefix + LocaleController.getString("StatusSize", R.string.StatusSize), String.format("%d", Integer.valueOf(Theme.contactsStatusSize)), true);
}
} else if (itemViewType == 3) {
textDetailSettingsCell = view == null ? new TextColorCell(this.mContext) : view;
TextColorCell textColorCell = (TextColorCell) textDetailSettingsCell;
textColorCell.setMultilineText();
if (i == ThemingContactsActivity.this.headerColorRow) {
textColorCell.setTag("contactsHeaderColor");
textColorCell.setTextAndColor(prefix + LocaleController.getString("HeaderColor", R.string.HeaderColor), Theme.contactsHeaderColor, false);
} else if (i == ThemingContactsActivity.this.headerGradientColorRow) {
textColorCell.setTag("contactsHeaderGradientColor");
textColorCell.setTextAndColor(prefix + LocaleController.getString("RowGradientColor", R.string.RowGradientColor), sharedPreferences.getInt("contactsHeaderGradient", 0) != 0 ? sharedPreferences.getInt("contactsHeaderGradientColor", Theme.defColor) : 0, true);
} else if (i == ThemingContactsActivity.this.headerTitleColorRow) {
textColorCell.setTag("contactsHeaderTitleColor");
textColorCell.setTextAndColor(prefix + LocaleController.getString("HeaderTitleColor", R.string.HeaderTitleColor), Theme.contactsHeaderTitleColor, true);
} else if (i == ThemingContactsActivity.this.headerIconsColorRow) {
textColorCell.setTag("contactsHeaderIconsColor");
textColorCell.setTextAndColor(prefix + LocaleController.getString("HeaderIconsColor", R.string.HeaderIconsColor), Theme.contactsHeaderIconsColor, false);
} else if (i == ThemingContactsActivity.this.iconsColorRow) {
textColorCell.setTag("contactsIconsColor");
textColorCell.setTextAndColor(prefix + LocaleController.getString("IconsColor", R.string.IconsColor), Theme.contactsIconsColor, true);
} else if (i == ThemingContactsActivity.this.rowColorRow) {
textColorCell.setTag("contactsRowColor");
textColorCell.setTextAndColor(prefix + LocaleController.getString("RowColor", R.string.RowColor), Theme.contactsRowColor, false);
} else if (i == ThemingContactsActivity.this.rowGradientColorRow) {
textColorCell.setTag("contactsRowGradientColor");
textColorCell.setTextAndColor(prefix + LocaleController.getString("RowGradientColor", R.string.RowGradientColor), sharedPreferences.getInt("contactsRowGradient", 0) != 0 ? sharedPreferences.getInt("contactsRowGradientColor", -1) : 0, true);
} else if (i == ThemingContactsActivity.this.nameColorRow) {
textColorCell.setTag("contactsNameColor");
textColorCell.setTextAndColor(prefix + LocaleController.getString("NameColor", R.string.NameColor), Theme.contactsNameColor, true);
} else if (i == ThemingContactsActivity.this.statusColorRow) {
textColorCell.setTag("contactsStatusColor");
textColorCell.setTextAndColor(prefix + LocaleController.getString("StatusColor", R.string.StatusColor), Theme.contactsStatusColor, true);
} else if (i == ThemingContactsActivity.this.onlineColorRow) {
textColorCell.setTag("contactsOnlineColor");
textColorCell.setTextAndColor(prefix + LocaleController.getString("OnlineColor", R.string.OnlineColor), Theme.contactsOnlineColor, false);
}
} else if (itemViewType == 4) {
textDetailSettingsCell = view == null ? new TextCheckCell(this.mContext) : view;
TextCheckCell textCheckCell = (TextCheckCell) textDetailSettingsCell;
if (i == ThemingContactsActivity.this.rowGradientListCheckRow) {
textCheckCell.setTag("contactsRowGradientListCheck");
textCheckCell.setTextAndCheck(prefix + LocaleController.getString("RowGradientList", R.string.RowGradientList), AndroidUtilities.getIntDef("contactsRowGradient", 0) != 0 ? sharedPreferences.getBoolean("contactsRowGradientListCheck", false) : false, true);
}
} else {
if (itemViewType == 5) {
textDetailSettingsCell = view == null ? new TextDetailSettingsCell(this.mContext) : view;
TextDetailSettingsCell textDetailSettingsCell2 = (TextDetailSettingsCell) textDetailSettingsCell;
if (i == ThemingContactsActivity.this.headerGradientRow) {
textDetailSettingsCell2.setTag("contactsHeaderGradient");
textDetailSettingsCell2.setMultilineDetail(false);
int i2 = sharedPreferences.getInt("contactsHeaderGradient", 0);
if (i2 == 0) {
textDetailSettingsCell2.setTextAndValue(prefix + LocaleController.getString("RowGradient", R.string.RowGradient), LocaleController.getString("RowGradientDisabled", R.string.RowGradientDisabled), false);
} else if (i2 == 1) {
textDetailSettingsCell2.setTextAndValue(prefix + LocaleController.getString("RowGradient", R.string.RowGradient), LocaleController.getString("RowGradientTopBottom", R.string.RowGradientTopBottom), false);
} else if (i2 == 2) {
textDetailSettingsCell2.setTextAndValue(prefix + LocaleController.getString("RowGradient", R.string.RowGradient), LocaleController.getString("RowGradientLeftRight", R.string.RowGradientLeftRight), false);
} else if (i2 == 3) {
textDetailSettingsCell2.setTextAndValue(prefix + LocaleController.getString("RowGradient", R.string.RowGradient), LocaleController.getString("RowGradientTLBR", R.string.RowGradientTLBR), false);
} else if (i2 == 4) {
textDetailSettingsCell2.setTextAndValue(prefix + LocaleController.getString("RowGradient", R.string.RowGradient), LocaleController.getString("RowGradientBLTR", R.string.RowGradientBLTR), false);
}
} else if (i == ThemingContactsActivity.this.rowGradientRow) {
textDetailSettingsCell2.setTag("contactsRowGradient");
textDetailSettingsCell2.setMultilineDetail(false);
int i3 = sharedPreferences.getInt("contactsRowGradient", 0);
if (i3 == 0) {
textDetailSettingsCell2.setTextAndValue(prefix + LocaleController.getString("RowGradient", R.string.RowGradient), LocaleController.getString("RowGradientDisabled", R.string.RowGradientDisabled), false);
} else if (i3 == 1) {
textDetailSettingsCell2.setTextAndValue(prefix + LocaleController.getString("RowGradient", R.string.RowGradient), LocaleController.getString("RowGradientTopBottom", R.string.RowGradientTopBottom), false);
} else if (i3 == 2) {
textDetailSettingsCell2.setTextAndValue(prefix + LocaleController.getString("RowGradient", R.string.RowGradient), LocaleController.getString("RowGradientLeftRight", R.string.RowGradientLeftRight), false);
} else if (i3 == 3) {
textDetailSettingsCell2.setTextAndValue(prefix + LocaleController.getString("RowGradient", R.string.RowGradient), LocaleController.getString("RowGradientTLBR", R.string.RowGradientTLBR), false);
} else if (i3 == 4) {
textDetailSettingsCell2.setTextAndValue(prefix + LocaleController.getString("RowGradient", R.string.RowGradient), LocaleController.getString("RowGradientBLTR", R.string.RowGradientBLTR), false);
}
}
}
textDetailSettingsCell = view;
}
if (textDetailSettingsCell != null) {
textDetailSettingsCell.setBackgroundColor(Theme.usePlusTheme ? Theme.prefBGColor : Theme.getColor(Theme.key_windowBackgroundWhite));
}
return textDetailSettingsCell;
}
@Override
public int getItemViewType(int i) {
if (i == ThemingContactsActivity.this.rowsSectionRow) {
return 0;
}
if (i == ThemingContactsActivity.this.headerSection2Row || i == ThemingContactsActivity.this.rowsSection2Row) {
return 1;
}
if (i == ThemingContactsActivity.this.avatarRadiusRow || i == ThemingContactsActivity.this.nameSizeRow || i == ThemingContactsActivity.this.statusSizeRow) {
return 2;
}
if (i == ThemingContactsActivity.this.headerColorRow || i == ThemingContactsActivity.this.headerGradientColorRow || i == ThemingContactsActivity.this.headerTitleColorRow || i == ThemingContactsActivity.this.headerIconsColorRow || i == ThemingContactsActivity.this.iconsColorRow || i == ThemingContactsActivity.this.rowColorRow || i == ThemingContactsActivity.this.rowGradientColorRow || i == ThemingContactsActivity.this.nameColorRow || i == ThemingContactsActivity.this.statusColorRow || i == ThemingContactsActivity.this.onlineColorRow) {
return 3;
}
if (i == ThemingContactsActivity.this.rowGradientListCheckRow) {
return 4;
}
return (i == ThemingContactsActivity.this.headerGradientRow || i == ThemingContactsActivity.this.rowGradientRow) ? 5 : 2;
}
}
}