mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Adapt some layouts.
This commit is contained in:
@@ -87,6 +87,7 @@ public class MrMailbox {
|
||||
public native static int MrMailboxOpen (long hMailbox, String dbfile, String blobdir);
|
||||
public native static void MrMailboxClose (long hMailbox);
|
||||
public native static int MrMailboxConfigure (long hMailbox);
|
||||
public native static int MrMailboxIsConfigured (long hMailbox);
|
||||
public native static int MrMailboxConnect (long hMailbox);
|
||||
public native static void MrMailboxDisconnect (long hMailbox);
|
||||
public native static int MrMailboxFetch (long hMailbox);
|
||||
@@ -98,7 +99,8 @@ public class MrMailbox {
|
||||
|
||||
public native static int MrMailboxSetConfig (long hMailbox, String key, String value); // value may be NULL
|
||||
public native static String MrMailboxGetConfig (long hMailbox, String key, String def); // def may be NULL, returns empty string as NULL
|
||||
public native static int MrMailboxIsConfigured (long hMailbox);
|
||||
|
||||
public native static String MrMailboxGetInfo (long hMailbox);
|
||||
|
||||
// MrChatlist objects
|
||||
public native static void MrChatlistUnref (long hChatlist);
|
||||
|
||||
@@ -45,6 +45,7 @@ import org.telegram.ui.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.ActionBar.BottomSheet;
|
||||
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
||||
import org.telegram.ui.Cells.CheckBoxCell;
|
||||
import org.telegram.ui.Cells.HeaderCell;
|
||||
import org.telegram.ui.Cells.TextInfoPrivacyCell;
|
||||
import org.telegram.ui.Cells.TextSettingsCell;
|
||||
import org.telegram.ui.Components.LayoutHelper;
|
||||
@@ -56,6 +57,7 @@ public class CacheControlActivity extends BaseFragment {
|
||||
|
||||
private ListAdapter listAdapter;
|
||||
|
||||
private int headlineRow; // EDIT BY MR -- added
|
||||
private int databaseRow;
|
||||
private int databaseInfoRow;
|
||||
private int keepMediaRow;
|
||||
@@ -64,6 +66,11 @@ public class CacheControlActivity extends BaseFragment {
|
||||
private int cacheInfoRow;
|
||||
private int rowCount;
|
||||
|
||||
private int typeTextSetting = 0; // EDIT BY MR -- no gaps, please
|
||||
private int typeTextInfo = 1;
|
||||
private int typeSectionTitle = 2;
|
||||
private int typeCount = 3; // /EDIT BY MR -- no gaps, please
|
||||
|
||||
private long databaseSize = -1;
|
||||
private long cacheSize = -1;
|
||||
private long documentsSize = -1;
|
||||
@@ -82,6 +89,7 @@ public class CacheControlActivity extends BaseFragment {
|
||||
super.onFragmentCreate();
|
||||
|
||||
rowCount = 0;
|
||||
headlineRow = -1;// rowCount++; // EDIT BY MR -- added
|
||||
keepMediaRow = rowCount++;
|
||||
keepMediaInfoRow = rowCount++;
|
||||
cacheRow = -1; // EDIT BY MR -- rowCount++;
|
||||
@@ -592,8 +600,17 @@ public class CacheControlActivity extends BaseFragment {
|
||||
|
||||
@Override
|
||||
public View getView(int i, View view, ViewGroup viewGroup) {
|
||||
int type = getItemViewType(i);
|
||||
if (type == 0) {
|
||||
int type_ = getItemViewType(i);
|
||||
if (type_ == typeSectionTitle) {
|
||||
if (view == null) {
|
||||
view = new HeaderCell(mContext);
|
||||
view.setBackgroundColor(0xffffffff);
|
||||
}
|
||||
if (i == headlineRow) {
|
||||
((HeaderCell) view).setText(LocaleController.getString("Settings", R.string.Settings));
|
||||
}
|
||||
}
|
||||
else if (type_ == typeTextSetting) {
|
||||
if (view == null) {
|
||||
view = new TextSettingsCell(mContext);
|
||||
view.setBackgroundColor(0xffffffff);
|
||||
@@ -620,7 +637,7 @@ public class CacheControlActivity extends BaseFragment {
|
||||
}
|
||||
textCell.setTextAndValue(LocaleController.getString("KeepMedia", R.string.KeepMedia), value, false);
|
||||
}
|
||||
} else if (type == 1) {
|
||||
} else if (type_ == typeTextInfo) {
|
||||
if (view == null) {
|
||||
view = new TextInfoPrivacyCell(mContext);
|
||||
}
|
||||
@@ -641,16 +658,19 @@ public class CacheControlActivity extends BaseFragment {
|
||||
@Override
|
||||
public int getItemViewType(int i) {
|
||||
if (i == databaseRow || i == cacheRow || i == keepMediaRow) {
|
||||
return 0;
|
||||
return typeTextSetting;
|
||||
} else if (i == databaseInfoRow || i == cacheInfoRow || i == keepMediaInfoRow) {
|
||||
return 1;
|
||||
return typeTextInfo;
|
||||
}
|
||||
return 0;
|
||||
else if(i==headlineRow) {
|
||||
return typeSectionTitle;
|
||||
}
|
||||
return typeTextSetting;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getViewTypeCount() {
|
||||
return 2;
|
||||
return typeCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -191,10 +191,12 @@ public class MrAccountSettingsActivity extends BaseFragment {
|
||||
// Warning: the widgets are created as needed and may not be present!
|
||||
String v;
|
||||
|
||||
/*
|
||||
if( !isModified() && MrMailbox.MrMailboxIsConfigured(MrMailbox.hMailbox)!=0 ) {
|
||||
finishFragment();
|
||||
return; // nothing to do
|
||||
}
|
||||
*/
|
||||
|
||||
if( addrCell!=null) {
|
||||
v = addrCell.getValue().trim();
|
||||
@@ -242,8 +244,12 @@ public class MrAccountSettingsActivity extends BaseFragment {
|
||||
}
|
||||
|
||||
MrMailbox.MrMailboxConfigure(MrMailbox.hMailbox);
|
||||
if( MrMailbox.MrMailboxConnect(MrMailbox.hMailbox)!=0 ) {
|
||||
MrMailbox.MrMailboxFetch(MrMailbox.hMailbox);
|
||||
}
|
||||
|
||||
// show dialog
|
||||
/*
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
||||
builder.setMessage("Testing the server connection, this may take a moment.");
|
||||
@@ -254,6 +260,9 @@ public class MrAccountSettingsActivity extends BaseFragment {
|
||||
}
|
||||
});
|
||||
showDialog(builder.create());
|
||||
*/
|
||||
|
||||
finishFragment(); // disable this when a dialog is used
|
||||
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.mainUserInfoChanged);
|
||||
}
|
||||
@@ -457,7 +466,7 @@ public class MrAccountSettingsActivity extends BaseFragment {
|
||||
|
||||
@Override
|
||||
public int getViewTypeCount() {
|
||||
return 1;
|
||||
return 1; /* SIC! internally, we ingnore the type, each row has its own type--otherwise text entry stuff would not work */
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -45,6 +45,7 @@ import org.telegram.ui.ActionBar.ActionBar;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
||||
import org.telegram.ui.Cells.HeaderCell;
|
||||
import org.telegram.ui.Cells.MrEditTextCell;
|
||||
import org.telegram.ui.Cells.TextInfoPrivacyCell;
|
||||
import org.telegram.ui.Cells.TextSettingsCell;
|
||||
@@ -56,12 +57,14 @@ public class MrNameSettingsActivity extends BaseFragment {
|
||||
// the list
|
||||
private ListAdapter listAdapter;
|
||||
|
||||
private int rowNameTitle;
|
||||
private int rowDisplayname;
|
||||
private int rowDisplaynameInfo;
|
||||
private int rowCount;
|
||||
|
||||
private final int typeInfo = 0; // no gaps here!
|
||||
private final int typeTextEntry = 1;
|
||||
private final int typeSection = 2;
|
||||
|
||||
MrEditTextCell displaynameCell; // warning all these objects may be null!
|
||||
|
||||
@@ -74,6 +77,7 @@ public class MrNameSettingsActivity extends BaseFragment {
|
||||
super.onFragmentCreate();
|
||||
|
||||
rowCount = 0;
|
||||
rowNameTitle = -1; // rowCount++;
|
||||
rowDisplayname = rowCount++;
|
||||
rowDisplaynameInfo = rowCount++;
|
||||
|
||||
@@ -211,12 +215,21 @@ public class MrNameSettingsActivity extends BaseFragment {
|
||||
@Override
|
||||
public View getView(int i, View view, ViewGroup viewGroup) {
|
||||
int type = getItemViewType__(i);
|
||||
if (type == typeTextEntry) {
|
||||
if (type == typeSection) {
|
||||
if (view == null) {
|
||||
view = new HeaderCell(mContext);
|
||||
view.setBackgroundColor(0xffffffff);
|
||||
}
|
||||
if (i == rowNameTitle) {
|
||||
((HeaderCell) view).setText(LocaleController.getString("MyName", R.string.MyName));
|
||||
}
|
||||
}
|
||||
else if (type == typeTextEntry) {
|
||||
if (i == rowDisplayname) {
|
||||
if(displaynameCell==null) {
|
||||
displaynameCell = new MrEditTextCell(mContext);
|
||||
displaynameCell.setValueHintAndLabel(MrMailbox.MrMailboxGetConfig(MrMailbox.hMailbox, "displayname", ""),
|
||||
"", LocaleController.getString("MyName", R.string.MyName), true);
|
||||
"", "", true);
|
||||
}
|
||||
view = displaynameCell;
|
||||
}
|
||||
@@ -241,13 +254,16 @@ public class MrNameSettingsActivity extends BaseFragment {
|
||||
if (i == rowDisplayname) {
|
||||
return typeTextEntry;
|
||||
}
|
||||
else if(i==rowNameTitle) {
|
||||
return typeSection;
|
||||
}
|
||||
return typeInfo;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getViewTypeCount() {
|
||||
return 1;
|
||||
return 1; /* SIC! internally, we ingnore the type, each row has its own type--otherwise text entry stuff would not work */
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -72,7 +72,7 @@ public class PrivacySettingsActivity extends BaseFragment implements Notificatio
|
||||
ContactsController.getInstance().loadPrivacySettings();
|
||||
|
||||
rowCount = 0;
|
||||
privacySectionRow = rowCount++;
|
||||
privacySectionRow = -1; //rowCount++;
|
||||
blockedRow = rowCount++;
|
||||
lastSeenRow = -1; // EDIT BY MR -- rowCount++;
|
||||
groupsRow = -1; // EDIT BY MR -- rowCount++;
|
||||
|
||||
@@ -59,6 +59,7 @@ import org.telegram.ui.Cells.HeaderCell;
|
||||
import org.telegram.ui.Cells.ShadowSectionCell;
|
||||
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.ActionBar.ActionBar;
|
||||
//import org.telegram.ui.ActionBar.ActionBarMenu; -- EDIT BY MR
|
||||
@@ -246,19 +247,17 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
askQuestionRow = -1; // EDIT BY MR -- rowCount++;
|
||||
telegramFaqRow = rowCount++;
|
||||
privacyPolicyRow = -1; // EDIT BY MR -- rowCount++;
|
||||
sendLogsRow = -1; // EDIT BY MR
|
||||
clearLogsRow = -1; // EDIT BY MR
|
||||
switchBackendButtonRow = -1; // EDIT BY MR
|
||||
/* EDIT BY MR
|
||||
if (BuildVars.DEBUG_VERSION) {
|
||||
sendLogsRow = rowCount++;
|
||||
clearLogsRow = rowCount++;
|
||||
switchBackendButtonRow = rowCount++;
|
||||
}
|
||||
// EDIT BY MR
|
||||
else {
|
||||
sendLogsRow = -1;
|
||||
clearLogsRow = -1;
|
||||
switchBackendButtonRow = -1;
|
||||
}
|
||||
// /EDIT BY MR
|
||||
versionRow = 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++;
|
||||
@@ -446,9 +445,13 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
*/
|
||||
}
|
||||
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);
|
||||
@@ -488,6 +491,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
} else if (i == languageRow) {
|
||||
presentFragment(new LanguageSelectActivity());
|
||||
} else if (i == switchBackendButtonRow) {
|
||||
/* EDIT BY MR
|
||||
if (getParentActivity() == null) {
|
||||
return;
|
||||
}
|
||||
@@ -502,9 +506,24 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
});
|
||||
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
||||
showDialog(builder.create());
|
||||
*/
|
||||
} else if (i == telegramFaqRow) {
|
||||
/* EDIT BY MR
|
||||
Browser.openUrl(getParentActivity(), LocaleController.getString("TelegramFaqUrl", R.string.TelegramFaqUrl));
|
||||
}
|
||||
*/
|
||||
// EDIT BY MR
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
builder.setTitle(LocaleController.getString("AppName", R.string.AppName) + " " + getVersion());
|
||||
builder.setMessage(MrMailbox.MrMailboxGetInfo(MrMailbox.hMailbox)+" Frontend based upon Telegram for Android.");
|
||||
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
;
|
||||
}
|
||||
});
|
||||
showDialog(builder.create());
|
||||
// /EDIT BY MR
|
||||
}
|
||||
else if (i == privacyPolicyRow) {
|
||||
/* EDIT BY MR
|
||||
Browser.openUrl(getParentActivity(), LocaleController.getString("PrivacyPolicyUrl", R.string.PrivacyPolicyUrl));
|
||||
@@ -664,6 +683,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
|
||||
@Override
|
||||
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
/* EDIT BY MR
|
||||
if (position == versionRow) {
|
||||
pressCount++;
|
||||
if (pressCount >= 2) {
|
||||
@@ -693,6 +713,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
}
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
});
|
||||
@@ -842,6 +863,34 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
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();
|
||||
@@ -1173,6 +1222,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
*/
|
||||
}
|
||||
|
||||
/* EDIT BY MR
|
||||
private void sendLogs() {
|
||||
try {
|
||||
ArrayList<Uri> uris = new ArrayList<>();
|
||||
@@ -1196,6 +1246,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
private class ListAdapter extends BaseFragmentAdapter {
|
||||
private Context mContext;
|
||||
@@ -1300,7 +1351,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
} else if (i == switchBackendButtonRow) {
|
||||
textCell.setText("Switch Backend", true);
|
||||
} else if (i == telegramFaqRow) {
|
||||
textCell.setText(LocaleController.getString("TelegramFAQ", R.string.TelegramFaq), true);
|
||||
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) {
|
||||
@@ -1342,7 +1393,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
if (i == settingsSectionRow2) {
|
||||
((HeaderCell) view).setText(LocaleController.getString("SETTINGS", R.string.SETTINGS));
|
||||
} else if (i == supportSectionRow2) {
|
||||
((HeaderCell) view).setText(LocaleController.getString("Support", R.string.Support));
|
||||
((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) {
|
||||
@@ -1352,7 +1403,8 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
}
|
||||
} else if (type == 5) {
|
||||
if (view == null) {
|
||||
view = new TextInfoCell(mContext);
|
||||
view = new TextInfoPrivacyCell(mContext);
|
||||
/* EDIT BY MR
|
||||
try {
|
||||
PackageInfo pInfo = ApplicationLoader.applicationContext.getPackageManager().getPackageInfo(ApplicationLoader.applicationContext.getPackageName(), 0);
|
||||
int code = pInfo.versionCode / 10;
|
||||
@@ -1371,11 +1423,11 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
abi = "universal";
|
||||
break;
|
||||
}
|
||||
((TextInfoCell) view).setText(String.format(Locale.US, "V%s (%d), Backend V%s (%s)",
|
||||
pInfo.versionName, code, MrMailbox.MrGetVersionStr(), abi)); // EDIT BY MR
|
||||
((TextInfoCell) view).setText(String.format(Locale.US, "Telegram for Android v%s (%d) %s", pInfo.versionName, code, abi));
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
*/
|
||||
}
|
||||
} else if (type == 6) {
|
||||
if (view == null) {
|
||||
|
||||
Reference in New Issue
Block a user