正在查看: Plus 12 v10.13.1.1 应用的 ThemingSettingsActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Plus 12 v10.13.1.1 应用的 ThemingSettingsActivity.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.TextSettingsCell;
public class ThemingSettingsActivity extends BaseFragment {
public int avatarColorRow;
public int avatarRadiusRow;
public int avatarSizeRow;
public int backgroundColorRow;
public int dividerColorRow;
public int headerColorRow;
public int headerIconsColorRow;
public int headerSection2Row;
public int headerStatusColorRow;
public int headerTitleColorRow;
public ListAdapter listAdapter;
public ListView listView;
public int rowCount;
public int rowsSection2Row;
public int scrollToPosition;
public int sectionColorRow;
public int shadowColorRow;
public boolean showPrefix;
public int summaryColorRow;
public int titleColorRow;
public ThemingSettingsActivity() {
}
public ThemingSettingsActivity(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.headerTitleColorRow = i2;
int i4 = i3 + 1;
this.rowCount = i4;
this.headerStatusColorRow = i3;
int i5 = i4 + 1;
this.rowCount = i5;
this.headerIconsColorRow = i4;
int i6 = i5 + 1;
this.rowCount = i6;
this.avatarColorRow = i5;
int i7 = i6 + 1;
this.rowCount = i7;
this.avatarRadiusRow = i6;
int i8 = i7 + 1;
this.rowCount = i8;
this.avatarSizeRow = i7;
int i9 = i8 + 1;
this.rowCount = i9;
int i10 = i9 + 1;
this.rowCount = i10;
this.rowsSection2Row = i9;
int i11 = i10 + 1;
this.rowCount = i11;
this.backgroundColorRow = i10;
int i12 = i11 + 1;
this.rowCount = i12;
this.shadowColorRow = i11;
int i13 = i12 + 1;
this.rowCount = i13;
this.sectionColorRow = i12;
int i14 = i13 + 1;
this.rowCount = i14;
this.titleColorRow = i13;
int i15 = i14 + 1;
this.rowCount = i15;
this.summaryColorRow = i14;
this.rowCount = i15 + 1;
this.dividerColorRow = i15;
this.showPrefix = ApplicationLoader.applicationContext.getSharedPreferences("plusconfig", 0).getBoolean("prefShowPrefix", 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() {
ThemingSettingsActivity.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() {
ThemingSettingsActivity.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.ThemingSettingsActivity.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 (ThemingSettingsActivity.this.getParentActivity() == null) {
return false;
}
final String obj = view.getTag() != null ? view.getTag().toString() : "";
AlertDialog.Builder builder = new AlertDialog.Builder(ThemingSettingsActivity.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 = ThemingSettingsActivity.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 (ThemingSettingsActivity.this.getParentActivity() != null) {
Toast.makeText(ThemingSettingsActivity.this.getParentActivity(), format, 0).show();
}
}
});
return;
} catch (Exception e) {
FileLog.e(e);
return;
}
}
if (intValue == 1) {
ThemingSettingsActivity.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);
ThemingSettingsActivity.this.getParentActivity().startActivityForResult(Intent.createChooser(intent, LocaleController.getString("ShareLink", R.string.ShareLink)), 500);
} catch (Exception e2) {
FileLog.e(e2);
}
}
}
});
ThemingSettingsActivity.this.showDialog(builder.create());
return true;
}
}
public final void resetPref(String key) {
SharedPreferences.Editor edit = ApplicationLoader.applicationContext.getSharedPreferences("theme", 0).edit();
edit.remove(key);
edit.commit();
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();
}
if (Theme.usePlusTheme) {
updateTheme();
}
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);
fixLayout();
}
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) ThemingSettingsActivity.this).fragmentView;
if (view2 == null) {
return false;
}
view2.getViewTreeObserver().removeOnPreDrawListener(this);
return false;
}
});
}
public final String getPrefix(int i) {
if (i == this.headerSection2Row) {
return "6.1 ";
}
int i2 = this.rowsSection2Row;
if (i == i2) {
return "6.2 ";
}
if (i < i2) {
return "6.1." + i + " ";
}
return "6.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 4;
}
@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) {
return i == ThemingSettingsActivity.this.headerColorRow || i == ThemingSettingsActivity.this.headerTitleColorRow || i == ThemingSettingsActivity.this.headerStatusColorRow || i == ThemingSettingsActivity.this.headerIconsColorRow || i == ThemingSettingsActivity.this.avatarColorRow || i == ThemingSettingsActivity.this.avatarRadiusRow || i == ThemingSettingsActivity.this.avatarSizeRow || i == ThemingSettingsActivity.this.backgroundColorRow || i == ThemingSettingsActivity.this.shadowColorRow || i == ThemingSettingsActivity.this.sectionColorRow || i == ThemingSettingsActivity.this.titleColorRow || i == ThemingSettingsActivity.this.summaryColorRow || i == ThemingSettingsActivity.this.dividerColorRow;
}
@Override
public int getCount() {
return ThemingSettingsActivity.this.rowCount;
}
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
int itemViewType = getItemViewType(i);
String prefix = ThemingSettingsActivity.this.showPrefix ? ThemingSettingsActivity.this.getPrefix(i) : "";
if (itemViewType == 0) {
if (view == null) {
view = new ShadowSectionCell(this.mContext);
}
} else if (itemViewType == 1) {
if (view == null) {
view = new HeaderCell(this.mContext);
view.setBackgroundColor(-1);
}
if (i == ThemingSettingsActivity.this.headerSection2Row) {
((HeaderCell) view).setText(prefix + LocaleController.getString("Header", R.string.Header));
} else if (i == ThemingSettingsActivity.this.rowsSection2Row) {
((HeaderCell) view).setText(prefix + LocaleController.getString("OptionsList", R.string.OptionsList));
}
} else if (itemViewType == 2) {
if (view == null) {
view = new TextColorCell(this.mContext);
}
TextColorCell textColorCell = (TextColorCell) view;
textColorCell.setMultilineText();
if (i == ThemingSettingsActivity.this.headerColorRow) {
textColorCell.setTag("prefHeaderColor");
textColorCell.setTextAndColor(prefix + LocaleController.getString("HeaderColor", R.string.HeaderColor), Theme.prefActionbarColor, true);
} else if (i == ThemingSettingsActivity.this.headerTitleColorRow) {
textColorCell.setTag("prefHeaderTitleColor");
textColorCell.setTextAndColor(prefix + LocaleController.getString("HeaderTitleColor", R.string.HeaderTitleColor), Theme.prefActionbarTitleColor, true);
} else if (i == ThemingSettingsActivity.this.headerStatusColorRow) {
textColorCell.setTag("prefHeaderStatusColor");
textColorCell.setTextAndColor(prefix + LocaleController.getString("StatusColor", R.string.StatusColor), Theme.prefActionbarStatusColor, true);
} else if (i == ThemingSettingsActivity.this.headerIconsColorRow) {
textColorCell.setTag("prefHeaderIconsColor");
textColorCell.setTextAndColor(prefix + LocaleController.getString("HeaderIconsColor", R.string.HeaderIconsColor), Theme.prefActionbarIconsColor, true);
} else if (i == ThemingSettingsActivity.this.avatarColorRow) {
textColorCell.setTag("prefAvatarColor");
textColorCell.setTextAndColor(prefix + LocaleController.getString("AvatarColor", R.string.AvatarColor), Theme.prefAvatarColor, true);
} else if (i == ThemingSettingsActivity.this.backgroundColorRow) {
textColorCell.setTag("prefBGColor");
textColorCell.setTextAndColor(prefix + LocaleController.getString("BackgroundColorPlus", R.string.BackgroundColorPlus), Theme.prefBGColor, true);
} else if (i == ThemingSettingsActivity.this.shadowColorRow) {
textColorCell.setTag("prefShadowColor");
textColorCell.setTextAndColor(prefix + LocaleController.getString("ShadowColor", R.string.ShadowColor), Theme.prefShadowColor, true);
} else if (i == ThemingSettingsActivity.this.sectionColorRow) {
textColorCell.setTag("prefSectionColor");
textColorCell.setTextAndColor(prefix + LocaleController.getString("SectionColor", R.string.SectionColor), Theme.prefSectionColor, true);
} else if (i == ThemingSettingsActivity.this.titleColorRow) {
textColorCell.setTag("prefTitleColor");
textColorCell.setTextAndColor(prefix + LocaleController.getString("TitleColor", R.string.TitleColor), Theme.prefTitleColor, true);
} else if (i == ThemingSettingsActivity.this.summaryColorRow) {
textColorCell.setTag("prefSummaryColor");
textColorCell.setTextAndColor(prefix + LocaleController.getString("SummaryColor", R.string.SummaryColor), Theme.prefSummaryColor, true);
} else if (i == ThemingSettingsActivity.this.dividerColorRow) {
textColorCell.setTag("prefDividerColor");
textColorCell.setTextAndColor(prefix + LocaleController.getString("DividerColor", R.string.DividerColor), Theme.prefDividerColor, true);
}
} else if (itemViewType == 3) {
if (view == null) {
view = new TextSettingsCell(this.mContext);
}
TextSettingsCell textSettingsCell = (TextSettingsCell) view;
SharedPreferences sharedPreferences = ApplicationLoader.applicationContext.getSharedPreferences("theme", 0);
if (i == ThemingSettingsActivity.this.avatarRadiusRow) {
textSettingsCell.setTag("prefAvatarRadius");
textSettingsCell.setTextAndValue(prefix + LocaleController.getString("AvatarRadius", R.string.AvatarRadius), String.format("%d", Integer.valueOf(sharedPreferences.getInt("prefAvatarRadius", AndroidUtilities.isTablet() ? 35 : 32))), true);
} else if (i == ThemingSettingsActivity.this.avatarSizeRow) {
textSettingsCell.setTag("prefAvatarSize");
textSettingsCell.setTextAndValue(prefix + LocaleController.getString("AvatarSize", R.string.AvatarSize), String.format("%d", Integer.valueOf(sharedPreferences.getInt("prefAvatarSize", AndroidUtilities.isTablet() ? 45 : 42))), false);
}
}
if (view != null) {
view.setBackgroundColor(Theme.usePlusTheme ? Theme.prefBGColor : Theme.getColor(Theme.key_windowBackgroundWhite));
}
return view;
}
@Override
public int getItemViewType(int i) {
if (i == ThemingSettingsActivity.this.avatarRadiusRow || i == ThemingSettingsActivity.this.avatarSizeRow) {
return 3;
}
if (i == ThemingSettingsActivity.this.headerColorRow || i == ThemingSettingsActivity.this.headerTitleColorRow || i == ThemingSettingsActivity.this.headerStatusColorRow || i == ThemingSettingsActivity.this.headerIconsColorRow || i == ThemingSettingsActivity.this.avatarColorRow || i == ThemingSettingsActivity.this.backgroundColorRow || i == ThemingSettingsActivity.this.shadowColorRow || i == ThemingSettingsActivity.this.sectionColorRow || i == ThemingSettingsActivity.this.titleColorRow || i == ThemingSettingsActivity.this.summaryColorRow || i == ThemingSettingsActivity.this.dividerColorRow) {
return 2;
}
return (i == ThemingSettingsActivity.this.headerSection2Row || i == ThemingSettingsActivity.this.rowsSection2Row) ? 1 : 0;
}
}
}