Import TGKit

Thanks to @Catogram
This commit is contained in:
Ivan K
2022-03-13 18:49:27 +03:00
parent d3f874e060
commit 286279978f
16 changed files with 687 additions and 0 deletions

View File

@@ -0,0 +1,332 @@
package ua.itaysonlab.tgkit;
import android.content.Context;
import android.util.SparseArray;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.R;
import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.ActionBar.ThemeDescription;
import org.telegram.ui.Cells.HeaderCell;
import org.telegram.ui.Cells.NotificationsCheckCell;
import org.telegram.ui.Cells.ShadowSectionCell;
import org.telegram.ui.Cells.TextCell;
import org.telegram.ui.Cells.TextCheckCell;
import org.telegram.ui.Cells.TextDetailSettingsCell;
import org.telegram.ui.Cells.TextInfoPrivacyCell;
import org.telegram.ui.Cells.TextSettingsCell;
import org.telegram.ui.Components.LayoutHelper;
import org.telegram.ui.Components.RecyclerListView;
import java.util.ArrayList;
import com.exteragram.messenger.preferences.BasePreferencesEntry;
import com.exteragram.messenger.prefviews.StickerSliderCell;
import ua.itaysonlab.tgkit.preference.TGKitCategory;
import ua.itaysonlab.tgkit.preference.TGKitPreference;
import ua.itaysonlab.tgkit.preference.TGKitSettings;
import ua.itaysonlab.tgkit.preference.types.TGKitHeaderRow;
import ua.itaysonlab.tgkit.preference.types.TGKitListPreference;
import ua.itaysonlab.tgkit.preference.types.TGKitSectionRow;
import ua.itaysonlab.tgkit.preference.types.TGKitSettingsCellRow;
import ua.itaysonlab.tgkit.preference.types.TGKitSliderPreference;
import ua.itaysonlab.tgkit.preference.types.TGKitSwitchPreference;
import ua.itaysonlab.tgkit.preference.types.TGKitTextDetailRow;
import ua.itaysonlab.tgkit.preference.types.TGKitTextIconRow;
public class TGKitSettingsFragment extends BaseFragment {
private final TGKitSettings settings;
private final SparseArray<TGKitPreference> positions = new SparseArray<>();
private ListAdapter listAdapter;
private RecyclerListView listView;
private int rowCount;
public TGKitSettingsFragment(BasePreferencesEntry entry) {
super();
this.settings = entry.getProcessedPrefs(this);
}
@Override
public boolean onFragmentCreate() {
super.onFragmentCreate();
rowCount = 0;
initSettings();
return true;
}
private void initSettings() {
for (TGKitCategory category : settings.categories) {
positions.put(rowCount++, new TGKitHeaderRow(category.name));
for (TGKitPreference preference : category.preferences) {
positions.put(rowCount++, preference);
}
positions.put(rowCount++, new TGKitSectionRow());
}
}
@Override
public View createView(Context context) {
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setTitle(settings.name);
if (AndroidUtilities.isTablet()) {
actionBar.setOccupyStatusBar(false);
}
actionBar.setAllowOverlayTitle(true);
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(int id) {
if (id == -1) {
finishFragment();
}
}
});
listAdapter = new ListAdapter(context);
fragmentView = new FrameLayout(context);
fragmentView.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundGray));
FrameLayout frameLayout = (FrameLayout) fragmentView;
listView = new RecyclerListView(context);
listView.setVerticalScrollBarEnabled(false);
listView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT));
listView.setAdapter(listAdapter);
listView.setOnItemClickListener((view, position, x, y) -> {
TGKitPreference pref = positions.get(position);
if (pref instanceof TGKitSwitchPreference) {
((TGKitSwitchPreference) pref).contract.toggleValue();
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(((TGKitSwitchPreference) pref).contract.getPreferenceValue());
}
} else if (pref instanceof TGKitTextIconRow) {
TGKitTextIconRow preference = ((TGKitTextIconRow) pref);
if (preference.listener != null) preference.listener.onClick(this);
} else if (pref instanceof TGKitSettingsCellRow) {
TGKitSettingsCellRow preference = ((TGKitSettingsCellRow) pref);
if (preference.listener != null) preference.listener.onClick(this);
} else if (pref instanceof TGKitListPreference) {
TGKitListPreference preference = ((TGKitListPreference) pref);
preference.callAction(this, getParentActivity(), view, x, y, () -> {
if (view instanceof TextSettingsCell)
((TextSettingsCell) view).setTextAndValue(preference.title, preference.getContract().getValue(), preference.getDivider());
});
}
});
return fragmentView;
}
@Override
public void onResume() {
super.onResume();
if (listAdapter != null) {
listAdapter.notifyDataSetChanged();
}
}
@Override
public ArrayList<ThemeDescription> getThemeDescriptions() {
ArrayList<ThemeDescription> themeDescriptions = new ArrayList<>();
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_CELLBACKGROUNDCOLOR, new Class[]{TextSettingsCell.class, TextCheckCell.class, HeaderCell.class, NotificationsCheckCell.class}, null, null, null, Theme.key_windowBackgroundWhite));
themeDescriptions.add(new ThemeDescription(fragmentView, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundGray));
themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_actionBarDefault));
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_LISTGLOWCOLOR, null, null, null, null, Theme.key_actionBarDefault));
themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_ITEMSCOLOR, null, null, null, null, Theme.key_actionBarDefaultIcon));
themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_TITLECOLOR, null, null, null, null, Theme.key_actionBarDefaultTitle));
themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SELECTORCOLOR, null, null, null, null, Theme.key_actionBarDefaultSelector));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{NotificationsCheckCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{NotificationsCheckCell.class}, new String[]{"valueTextView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayText2));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{NotificationsCheckCell.class}, new String[]{"checkBox"}, null, null, null, Theme.key_switchTrack));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{NotificationsCheckCell.class}, new String[]{"checkBox"}, null, null, null, Theme.key_switchTrackChecked));
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_SELECTOR, null, null, null, null, Theme.key_listSelector));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{View.class}, Theme.dividerPaint, null, null, Theme.key_divider));
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_BACKGROUNDFILTER, new Class[]{ShadowSectionCell.class}, null, null, null, Theme.key_windowBackgroundGrayShadow));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{TextSettingsCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{TextSettingsCell.class}, new String[]{"valueTextView"}, null, null, null, Theme.key_windowBackgroundWhiteValueText));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{HeaderCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlueHeader));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{TextCheckCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{TextCheckCell.class}, new String[]{"valueTextView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayText2));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{TextCheckCell.class}, new String[]{"checkBox"}, null, null, null, Theme.key_switchTrack));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{TextCheckCell.class}, new String[]{"checkBox"}, null, null, null, Theme.key_switchTrackChecked));
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_BACKGROUNDFILTER, new Class[]{TextInfoPrivacyCell.class}, null, null, null, Theme.key_windowBackgroundGrayShadow));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{TextInfoPrivacyCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayText4));
return themeDescriptions;
}
private class ListAdapter extends RecyclerListView.SelectionAdapter {
private final Context mContext;
ListAdapter(Context context) {
mContext = context;
}
@Override
public int getItemCount() {
return rowCount;
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
switch (holder.getItemViewType()) {
case 0: {
holder.itemView.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
break;
}
case 1: {
TextSettingsCell textCell = (TextSettingsCell) holder.itemView;
textCell.setCanDisable(false);
TGKitSettingsCellRow pref = (TGKitSettingsCellRow) positions.get(position);
textCell.setTextColor(pref.textColor);
textCell.setText(pref.title, pref.divider);
break;
}
case 2: {
((HeaderCell) holder.itemView).setText(positions.get(position).title);
break;
}
case 3: {
TextCheckCell checkCell = (TextCheckCell) holder.itemView;
TGKitSwitchPreference pref = (TGKitSwitchPreference) positions.get(position);
if (pref.summary != null) {
checkCell.setTextAndValueAndCheck(pref.title, pref.summary, pref.contract.getPreferenceValue(), true, pref.divider);
} else {
checkCell.setTextAndCheck(pref.title, pref.contract.getPreferenceValue(), pref.divider);
}
break;
}
case 4: {
TextDetailSettingsCell settingsCell = (TextDetailSettingsCell) holder.itemView;
TGKitTextDetailRow pref = (TGKitTextDetailRow) positions.get(position);
settingsCell.setMultilineDetail(true);
settingsCell.setTextAndValue(pref.title, pref.detail, pref.divider);
break;
}
case 5: {
TextCell cell = (TextCell) holder.itemView;
((TGKitTextIconRow) positions.get(position)).bindCell(cell);
break;
}
case 6: {
((StickerSliderCell) holder.itemView).setContract(((TGKitSliderPreference) positions.get(position)).contract);
break;
}
case 7: {
TextDetailSettingsCell settingsCell = (TextDetailSettingsCell) holder.itemView;
TGKitListPreference pref = (TGKitListPreference) positions.get(position);
settingsCell.setMultilineDetail(true);
settingsCell.setTextAndValue(pref.title, pref.getContract().getValue(), pref.getDivider());
break;
}
case 8: {
((TextInfoPrivacyCell) holder.itemView).setText(positions.get(position).title);
break;
}
case 9: {
TextSettingsCell settingsCell = (TextSettingsCell) holder.itemView;
TGKitListPreference pref = (TGKitListPreference) positions.get(position);
settingsCell.setCanDisable(false);
settingsCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
settingsCell.setTextAndValue(pref.title, pref.getContract().getValue(), pref.getDivider());
}
}
}
@Override
public void onViewAttachedToWindow(RecyclerView.ViewHolder holder) {
int viewType = holder.getItemViewType();
if (viewType == 3) {
int position = holder.getAdapterPosition();
TextCheckCell checkCell = (TextCheckCell) holder.itemView;
checkCell.setChecked(((TGKitSwitchPreference) positions.get(position)).contract.getPreferenceValue());
} else if (viewType == 9) {
int position = holder.getAdapterPosition();
TextSettingsCell checkCell = (TextSettingsCell) holder.itemView;
TGKitListPreference pref = ((TGKitListPreference) positions.get(position));
checkCell.setCanDisable(false);
checkCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
checkCell.setTextAndValue(pref.title, pref.getContract().getValue(), pref.getDivider());
}
}
public boolean isRowEnabled(int position) {
return positions.get(position).getType().enabled;
}
@Override
public boolean isEnabled(RecyclerView.ViewHolder holder) {
return isRowEnabled(holder.getAdapterPosition());
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = null;
switch (viewType) {
case 0:
view = new ShadowSectionCell(mContext);
break;
case 9:
case 1:
view = new TextSettingsCell(mContext);
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
break;
case 2:
view = new HeaderCell(mContext);
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
break;
case 3:
view = new TextCheckCell(mContext);
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
break;
case 4:
case 7:
view = new TextDetailSettingsCell(mContext);
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
break;
case 5:
view = new TextCell(mContext);
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
break;
case 6:
view = new StickerSliderCell(mContext);
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
break;
case 8:
view = new TextInfoPrivacyCell(mContext);
}
view.setLayoutParams(new RecyclerView.LayoutParams(RecyclerView.LayoutParams.MATCH_PARENT, RecyclerView.LayoutParams.WRAP_CONTENT));
return new RecyclerListView.Holder(view);
}
@Override
public int getItemViewType(int position) {
return positions.get(position).getType().adapterType;
}
}
}

View File

@@ -0,0 +1,78 @@
package ua.itaysonlab.tgkit.ktx
import androidx.core.util.Pair
import ua.itaysonlab.tgkit.preference.TGKitCategory
import ua.itaysonlab.tgkit.preference.TGKitPreference
import ua.itaysonlab.tgkit.preference.TGKitSettings
import ua.itaysonlab.tgkit.preference.types.*
fun tgKitScreen(name: String, block: TGKitScreen.() -> Unit) = TGKitSettings(name, mutableListOf<TGKitCategory>().apply(block))
fun TGKitScreen.category(name: String, block: TGKitPreferences.() -> Unit) = add(
TGKitCategory(name, mutableListOf<TGKitPreference>().apply(block))
)
fun TGKitPreferences.list(block: TGKitListPreference.() -> Unit) = add(TGKitListPreference().apply(block))
fun TGKitPreferences.switch(block: TGKitSwitchPreference.() -> Unit) = add(TGKitSwitchPreference().apply(block))
fun TGKitPreferences.slider(block: TGKitSliderPreference.() -> Unit) = add(TGKitSliderPreference().apply(block))
fun TGKitPreferences.textIcon(block: TGKitTextIconRow.() -> Unit) = add(TGKitTextIconRow().apply(block))
fun TGKitPreferences.textDetail(block: TGKitTextDetailRow.() -> Unit) = add(TGKitTextDetailRow().apply(block))
fun TGKitPreferences.hint(text: String) = add(TGKitTextHintRow().also { it.title = text })
fun TGKitSwitchPreference.contract(getValue: () -> Boolean, setValue: (Boolean) -> Unit) {
contract = object : TGKitSwitchPreference.TGSPContract {
override fun getPreferenceValue() = getValue()
override fun toggleValue() = setValue(!getValue())
}
}
fun TGKitListPreference.contract(getOptions: () -> List<Pair<Int, String>>, getValue: () -> String, setValue: (Int) -> Unit) {
contract = object : TGKitListPreference.TGTLContract {
override fun setValue(id: Int) {
setValue(id)
}
override fun hasIcons(): Boolean {
return false
}
override fun getOptionsIcons(): MutableList<Triple<Int, String, Int>> {
return mutableListOf()
}
override fun getValue(): String {
return getValue()
}
override fun getOptions(): List<Pair<Int, String>> {
return getOptions()
}
}
}
fun TGKitListPreference.contractIcons(getOptions: () -> List<Triple<Int, String, Int>>, getValue: () -> String, setValue: (Int) -> Unit) {
contract = object : TGKitListPreference.TGTLContract {
override fun setValue(id: Int) {
setValue(id)
}
override fun hasIcons(): Boolean {
return true
}
override fun getOptionsIcons(): List<Triple<Int, String, Int>> {
return getOptions()
}
override fun getValue(): String {
return getValue()
}
override fun getOptions(): List<Pair<Int, String>> {
return mutableListOf()
}
}
}
typealias TGKitScreen = MutableList<TGKitCategory>
typealias TGKitPreferences = MutableList<TGKitPreference>

View File

@@ -0,0 +1,13 @@
package ua.itaysonlab.tgkit.preference;
import java.util.List;
public class TGKitCategory {
public String name;
public List<TGKitPreference> preferences;
public TGKitCategory(String name, List<TGKitPreference> preferences) {
this.name = name;
this.preferences = preferences;
}
}

View File

@@ -0,0 +1,9 @@
package ua.itaysonlab.tgkit.preference;
import ua.itaysonlab.tgkit.preference.types.TGPType;
abstract public class TGKitPreference {
public String title;
abstract public TGPType getType();
}

View File

@@ -0,0 +1,13 @@
package ua.itaysonlab.tgkit.preference;
import java.util.List;
public class TGKitSettings {
public String name;
public List<TGKitCategory> categories;
public TGKitSettings(String name, List<TGKitCategory> categories) {
this.name = name;
this.categories = categories;
}
}

View File

@@ -0,0 +1,14 @@
package ua.itaysonlab.tgkit.preference.types;
import ua.itaysonlab.tgkit.preference.TGKitPreference;
public class TGKitHeaderRow extends TGKitPreference {
public TGKitHeaderRow(String title) {
this.title = title;
}
@Override
public TGPType getType() {
return TGPType.HEADER;
}
}

View File

@@ -0,0 +1,60 @@
package ua.itaysonlab.tgkit.preference.types
import android.app.Activity
import android.view.View
import androidx.core.util.Pair
import org.telegram.ui.ActionBar.BaseFragment
import org.telegram.ui.Components.AlertsCreator
import ua.itaysonlab.tgkit.preference.TGKitPreference
class TGKitListPreference : TGKitPreference() {
var divider = false
var contract: TGTLContract? = null
override fun getType(): TGPType {
return TGPType.LIST
}
fun callAction(bf: BaseFragment, pr: Activity, view: View, x: Float, y: Float, ti: TempInterface) {
var selected: Int = 0
val titleArray = mutableListOf<String>()
val idArray = mutableListOf<Int>()
if (contract!!.hasIcons()) {
contract!!.getOptionsIcons().forEachIndexed { index, triple ->
titleArray.add(triple.second)
idArray.add(triple.first)
if (contract!!.getValue() == triple.second) selected = index
}
} else {
contract!!.getOptions().forEachIndexed { index, pair ->
titleArray.add(pair.second)
idArray.add(pair.first)
if (contract!!.getValue() == pair.second) selected = index
}
}
val d = AlertsCreator.createSingleChoiceDialog(pr, titleArray.toTypedArray(), title, selected) { di, sel ->
contract!!.setValue(idArray[sel])
ti.update()
}
bf.visibleDialog = d
d.show()
}
interface TGTLContract {
fun setValue(id: Int)
fun getValue(): String
fun getOptions(): List<Pair<Int, String>>
fun getOptionsIcons(): List<Triple<Int, String, Int?>>
fun hasIcons(): Boolean
}
interface TempInterface {
fun update()
}
}

View File

@@ -0,0 +1,10 @@
package ua.itaysonlab.tgkit.preference.types;
import ua.itaysonlab.tgkit.preference.TGKitPreference;
public class TGKitSectionRow extends TGKitPreference {
@Override
public TGPType getType() {
return TGPType.SECTION;
}
}

View File

@@ -0,0 +1,20 @@
package ua.itaysonlab.tgkit.preference.types;
import androidx.annotation.Nullable;
import org.telegram.ui.ActionBar.Theme;
import ua.itaysonlab.tgkit.preference.TGKitPreference;
public class TGKitSettingsCellRow extends TGKitPreference {
public boolean divider = false;
public int textColor = Theme.getColor(Theme.key_windowBackgroundWhiteBlackText);
@Nullable
public TGKitTextIconRow.TGTIListener listener;
@Override
public TGPType getType() {
return TGPType.TEXT_ICON;
}
}

View File

@@ -0,0 +1,27 @@
package ua.itaysonlab.tgkit.preference.types;
import androidx.annotation.Nullable;
import ua.itaysonlab.tgkit.preference.TGKitPreference;
public class TGKitSliderPreference extends TGKitPreference {
public TGSLContract contract;
@Nullable
public String summary;
@Override
public TGPType getType() {
return TGPType.SLIDER;
}
public interface TGSLContract {
void setValue(int value);
int getPreferenceValue();
int getMin();
int getMax();
}
}

View File

@@ -0,0 +1,24 @@
package ua.itaysonlab.tgkit.preference.types;
import androidx.annotation.Nullable;
import ua.itaysonlab.tgkit.preference.TGKitPreference;
public class TGKitSwitchPreference extends TGKitPreference {
public TGSPContract contract;
public boolean divider = false;
@Nullable
public String summary;
@Override
public TGPType getType() {
return TGPType.SWITCH;
}
public interface TGSPContract {
boolean getPreferenceValue();
void toggleValue();
}
}

View File

@@ -0,0 +1,13 @@
package ua.itaysonlab.tgkit.preference.types;
import ua.itaysonlab.tgkit.preference.TGKitPreference;
public class TGKitTextDetailRow extends TGKitPreference {
public String detail;
public boolean divider;
@Override
public TGPType getType() {
return TGPType.TEXT_DETAIL;
}
}

View File

@@ -0,0 +1,12 @@
package ua.itaysonlab.tgkit.preference.types;
import ua.itaysonlab.tgkit.preference.TGKitPreference;
public class TGKitTextHintRow extends TGKitPreference {
public boolean divider;
@Override
public TGPType getType() {
return TGPType.HINT;
}
}

View File

@@ -0,0 +1,40 @@
package ua.itaysonlab.tgkit.preference.types;
import androidx.annotation.Nullable;
import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.Cells.TextCell;
import ua.itaysonlab.tgkit.preference.TGKitPreference;
public class TGKitTextIconRow extends TGKitPreference {
public boolean divider = false;
public int icon = -1;
@Nullable
public String value = null;
@Nullable
public TGTIListener listener;
public void bindCell(TextCell cell) {
if (icon != -1 && value != null) {
cell.setTextAndValueAndIcon(title, value, icon, divider);
} else if (value != null) {
cell.setTextAndValue(title, value, divider);
} else if (icon != -1) {
cell.setTextAndIcon(title, icon, divider);
} else {
cell.setText(title, divider);
}
}
@Override
public TGPType getType() {
return TGPType.TEXT_ICON;
}
public interface TGTIListener {
void onClick(BaseFragment bf);
}
}

View File

@@ -0,0 +1,21 @@
package ua.itaysonlab.tgkit.preference.types;
public enum TGPType {
SECTION(0, false),
SETTINGS_CELL(2, true),
HEADER(2, false),
SWITCH(3, true),
TEXT_DETAIL(4, true),
TEXT_ICON(5, true),
SLIDER(6, true),
HINT(8, true),
LIST(9, true);
public int adapterType;
public boolean enabled;
TGPType(int adapterType, boolean enabled) {
this.adapterType = adapterType;
this.enabled = enabled;
}
}

View File

@@ -3,4 +3,5 @@
<!-- exteraGram's Main Strings -->
<string name="exteraAppName">exteraGram</string>
<string name="exteraAppNameBeta">exteraGram β</string>
<string name="exteraDebugMenu">¯\\_(ツ)_/¯</string>
</resources>