forked from NextAlone/Nagram
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'target/dev' into dev
- Loading branch information
Showing
13 changed files
with
256 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
TMessagesProj/src/main/java/tw/nekomimi/nekogram/config/cell/ConfigCellText.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package tw.nekomimi.nekogram.config.cell; | ||
|
||
import androidx.recyclerview.widget.RecyclerView; | ||
import org.telegram.messenger.LocaleController; | ||
import org.telegram.ui.Cells.TextSettingsCell; | ||
import tw.nekomimi.nekogram.config.CellGroup; | ||
|
||
public class ConfigCellText extends AbstractConfigCell implements WithKey, WithOnClick { | ||
private final String key; | ||
private final String value; | ||
private final Runnable onClick; | ||
private boolean enabled = true; | ||
private TextSettingsCell cell; | ||
|
||
public ConfigCellText(String key, String customValue, Runnable onClick) { | ||
this.key = key; | ||
this.value = (customValue == null) ? "" : customValue; | ||
this.onClick = onClick; | ||
} | ||
|
||
public ConfigCellText(String key, Runnable onClick) { | ||
this(key, null, onClick); | ||
} | ||
|
||
public int getType() { | ||
return CellGroup.ITEM_TYPE_TEXT_SETTINGS_CELL; | ||
} | ||
|
||
public String getKey() { | ||
return key; | ||
} | ||
|
||
public boolean isEnabled() { | ||
return enabled; | ||
} | ||
|
||
public void setEnabled(boolean enabled) { | ||
this.enabled = enabled; | ||
if (this.cell != null) this.cell.setEnabled(this.enabled); | ||
} | ||
|
||
public void onBindViewHolder(RecyclerView.ViewHolder holder) { | ||
TextSettingsCell cell = (TextSettingsCell) holder.itemView; | ||
this.cell = cell; | ||
String title = LocaleController.getString(key); | ||
cell.setTextAndValue(title, value, cellGroup.needSetDivider(this)); | ||
cell.setEnabled(enabled); | ||
} | ||
|
||
public void onClick() { | ||
if (!enabled) return; | ||
if (onClick != null) { | ||
try { | ||
onClick.run(); | ||
} catch (Exception ignored) {} | ||
} | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
TMessagesProj/src/main/java/tw/nekomimi/nekogram/config/cell/WithKey.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package tw.nekomimi.nekogram.config.cell; | ||
|
||
public interface WithKey { | ||
String getKey(); | ||
} |
5 changes: 5 additions & 0 deletions
5
TMessagesProj/src/main/java/tw/nekomimi/nekogram/config/cell/WithOnClick.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package tw.nekomimi.nekogram.config.cell; | ||
|
||
public interface WithOnClick { | ||
void onClick(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.