Standalone starting.

This commit is contained in:
B. Petersen
2016-10-07 18:13:37 +02:00
parent 4c686bb278
commit 12cbce4252
12 changed files with 102 additions and 34 deletions
@@ -608,7 +608,11 @@ public class MessagesController implements NotificationCenter.NotificationCenter
}
public TLRPC.User getUser(Integer id) {
return users.get(id);
// EDIT BY MR
TLRPC.User u = new TLRPC.User();
u.id = id;
return u;
//return users.get(id); -- /EDIT BY MR
}
public TLRPC.User getUser(String username) {
@@ -4411,6 +4415,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
}
}
/* EDIT BY MR
public void performLogout(boolean byUser) {
SharedPreferences.Editor editor = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE).edit();
editor.clear().commit();
@@ -4437,6 +4442,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
cleanup();
ContactsController.getInstance().deleteAllAppAccounts();
}
*/
public void generateUpdateMessage() {
if (BuildVars.DEBUG_VERSION || UserConfig.lastUpdateVersion == null || UserConfig.lastUpdateVersion.equals(BuildVars.BUILD_VERSION_STRING)) {
@@ -119,15 +119,21 @@ public class UserConfig {
}
public static boolean isClientActivated() {
return true; // EDIT BY MR -- for "real" checking, call MrMailbox.MrMailboxIsConfigured()
/* EDIT BY MR
synchronized (sync) {
return currentUser != null;
}
*/
}
public static int getClientUserId() {
return 1; // we are user #1 by definition
/* EDIT BY MR
synchronized (sync) {
return currentUser != null ? currentUser.id : 0;
}
*/
}
public static TLRPC.User getCurrentUser() {
@@ -321,6 +321,7 @@ public class ConnectionsManager {
}
public static void onLogout() {
/*
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
@@ -330,6 +331,7 @@ public class ConnectionsManager {
}
}
});
*/
}
public static void onUpdateConfig(int address) {
@@ -533,6 +533,7 @@ public class ActionBar extends FrameLayout {
}
public void setTitleOverlayText(String text) {
/* EDIT BY MR
if (!allowOverlayTitle || parentFragment.parentLayout == null) {
return;
}
@@ -544,6 +545,7 @@ public class ActionBar extends FrameLayout {
titleTextView.setVisibility(textToSet != null && !isSearchFieldVisible ? VISIBLE : INVISIBLE);
titleTextView.setText(textToSet);
}
*/
}
public boolean isSearchFieldVisible() {
@@ -27,6 +27,23 @@ public class DrawerLayoutAdapter extends BaseAdapter {
private Context mContext;
// EDIT BY MR
public final static int iProfile = 0;
public final static int iEmptyBelowProfile = 1;
public final static int iNewGroup = 2;
public final static int iNewSecretChat = 3;
public final static int iNewChannel = 4;
public final static int iDivider = 5;
public final static int iContacts = 6;
public final static int iInviteFriends = 7;
public final static int iSettings = 8;
public final static int iFaq = 9;
public final static int iCount = 10;
// disabled:
// EDIT BY MR
public DrawerLayoutAdapter(Context context) {
mContext = context;
}
@@ -38,12 +55,12 @@ public class DrawerLayoutAdapter extends BaseAdapter {
@Override
public boolean isEnabled(int i) {
return !(i == 0 || i == 1 || i == 5);
return !(i == iProfile || i == iEmptyBelowProfile || i == iDivider);
}
@Override
public int getCount() {
return UserConfig.isClientActivated() ? 10 : 0;
return UserConfig.isClientActivated() ? iCount : 0;
}
@Override
@@ -82,19 +99,19 @@ public class DrawerLayoutAdapter extends BaseAdapter {
view = new DrawerActionCell(mContext);
}
DrawerActionCell actionCell = (DrawerActionCell) view;
if (i == 2) {
if (i == iNewGroup) {
actionCell.setTextAndIcon(LocaleController.getString("NewGroup", R.string.NewGroup), R.drawable.menu_newgroup);
} else if (i == 3) {
} else if (i == iNewSecretChat) {
actionCell.setTextAndIcon(LocaleController.getString("NewSecretChat", R.string.NewSecretChat), R.drawable.menu_secret);
} else if (i == 4) {
} else if (i == iNewChannel) {
actionCell.setTextAndIcon(LocaleController.getString("NewChannel", R.string.NewChannel), R.drawable.menu_broadcast);
} else if (i == 6) {
} else if (i == iContacts) {
actionCell.setTextAndIcon(LocaleController.getString("Contacts", R.string.Contacts), R.drawable.menu_contacts);
} else if (i == 7) {
} else if (i == iInviteFriends) {
actionCell.setTextAndIcon(LocaleController.getString("InviteFriends", R.string.InviteFriends), R.drawable.menu_invite);
} else if (i == 8) {
} else if (i == iSettings) {
actionCell.setTextAndIcon(LocaleController.getString("Settings", R.string.Settings), R.drawable.menu_settings);
} else if (i == 9) {
} else if (i == iFaq) {
actionCell.setTextAndIcon(LocaleController.getString("TelegramFaq", R.string.TelegramFaq), R.drawable.menu_help);
}
}
@@ -104,11 +121,11 @@ public class DrawerLayoutAdapter extends BaseAdapter {
@Override
public int getItemViewType(int i) {
if (i == 0) {
if (i == iProfile) {
return 0;
} else if (i == 1) {
} else if (i == iEmptyBelowProfile) {
return 1;
} else if (i == 5) {
} else if (i == iDivider) {
return 2;
}
return 3;
@@ -332,6 +332,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
args.putBoolean("allowBots", false);
presentFragment(new ContactsActivity(args), false);
} else if (row == 2) {
/* EDIT BY MR
if (!MessagesController.isFeatureEnabled("broadcast_create", ContactsActivity.this)) {
return;
}
@@ -344,6 +345,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
presentFragment(new ChannelIntroActivity());
preferences.edit().putBoolean("channel_intro", true).commit();
}
*/
}
}
} else {
@@ -84,7 +84,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
private DialogsAdapter dialogsAdapter;
private DialogsSearchAdapter dialogsSearchAdapter;
private EmptyTextProgressView searchEmptyView;
private ProgressBar progressView;
//private ProgressBar progressView;
private LinearLayout emptyView;
private ActionBarMenuItem passcodeItem;
private ImageView floatingButton;
@@ -208,7 +208,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
if (listView != null) {
if (searchString != null) {
listView.setEmptyView(searchEmptyView);
progressView.setVisibility(View.GONE);
//progressView.setVisibility(View.GONE);
emptyView.setVisibility(View.GONE);
}
if (!onlySelect) {
@@ -233,11 +233,14 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
searchWas = false;
if (listView != null) {
searchEmptyView.setVisibility(View.GONE);
/*)
if (MessagesController.getInstance().loadingDialogs && MessagesController.getInstance().dialogs.isEmpty()) {
emptyView.setVisibility(View.GONE);
listView.setEmptyView(progressView);
} else {
progressView.setVisibility(View.GONE);
} else
*/
{
//progressView.setVisibility(View.GONE);
listView.setEmptyView(emptyView);
}
if (!onlySelect) {
@@ -268,7 +271,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
}
if (searchEmptyView != null && listView.getEmptyView() != searchEmptyView) {
emptyView.setVisibility(View.GONE);
progressView.setVisibility(View.GONE);
//progressView.setVisibility(View.GONE);
searchEmptyView.showTextView();
listView.setEmptyView(searchEmptyView);
}
@@ -649,9 +652,11 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
textView.setLineSpacing(AndroidUtilities.dp(2), 1);
emptyView.addView(textView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT));
/*
progressView = new ProgressBar(context);
progressView.setVisibility(View.GONE);
frameLayout.addView(progressView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER));
*/
floatingButton = new ImageView(context);
floatingButton.setVisibility(onlySelect ? View.GONE : View.VISIBLE);
@@ -814,13 +819,16 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
}
});
/* EDIT BY MR -- avoid rotating wheel
if (MessagesController.getInstance().loadingDialogs && MessagesController.getInstance().dialogs.isEmpty()) {
searchEmptyView.setVisibility(View.GONE);
emptyView.setVisibility(View.GONE);
listView.setEmptyView(progressView);
} else {
} else
*/
{
searchEmptyView.setVisibility(View.GONE);
progressView.setVisibility(View.GONE);
//progressView.setVisibility(View.GONE);
listView.setEmptyView(emptyView);
}
if (searchString != null) {
@@ -952,12 +960,15 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
}
if (listView != null) {
try {
/*
if (MessagesController.getInstance().loadingDialogs && MessagesController.getInstance().dialogs.isEmpty()) {
searchEmptyView.setVisibility(View.GONE);
emptyView.setVisibility(View.GONE);
listView.setEmptyView(progressView);
} else {
progressView.setVisibility(View.GONE);
} else
*/
{
//progressView.setVisibility(View.GONE);
if (searching && searchWas) {
emptyView.setVisibility(View.GONE);
listView.setEmptyView(searchEmptyView);
@@ -292,13 +292,13 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (position == 2) {
if (position == DrawerLayoutAdapter.iNewGroup) {
if (!MessagesController.isFeatureEnabled("chat_create", actionBarLayout.fragmentsStack.get(actionBarLayout.fragmentsStack.size() - 1))) {
return;
}
presentFragment(new GroupCreateActivity());
drawerLayoutContainer.closeDrawer(false);
} else if (position == 3) {
} else if (position == DrawerLayoutAdapter.iNewSecretChat) {
Bundle args = new Bundle();
args.putBoolean("onlyUsers", true);
args.putBoolean("destroyAfterSelect", true);
@@ -306,7 +306,8 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
args.putBoolean("allowBots", false);
presentFragment(new ContactsActivity(args));
drawerLayoutContainer.closeDrawer(false);
} else if (position == 4) {
} else if (position == DrawerLayoutAdapter.iNewChannel) {
/* EDIT BY MR
if (!MessagesController.isFeatureEnabled("broadcast_create", actionBarLayout.fragmentsStack.get(actionBarLayout.fragmentsStack.size() - 1))) {
return;
}
@@ -320,10 +321,11 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
preferences.edit().putBoolean("channel_intro", true).commit();
}
drawerLayoutContainer.closeDrawer(false);
} else if (position == 6) {
*/
} else if (position == DrawerLayoutAdapter.iContacts) {
presentFragment(new ContactsActivity(null));
drawerLayoutContainer.closeDrawer(false);
} else if (position == 7) {
} else if (position == DrawerLayoutAdapter.iInviteFriends) {
try {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
@@ -333,10 +335,10 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
FileLog.e("tmessages", e);
}
drawerLayoutContainer.closeDrawer(false);
} else if (position == 8) {
} else if (position == DrawerLayoutAdapter.iSettings) {
presentFragment(new SettingsActivity());
drawerLayoutContainer.closeDrawer(false);
} else if (position == 9) {
} else if (position == DrawerLayoutAdapter.iFaq) {
Browser.openUrl(LaunchActivity.this, LocaleController.getString("TelegramFaqUrl", R.string.TelegramFaqUrl));
drawerLayoutContainer.closeDrawer(false);
}
@@ -405,20 +407,24 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
}
break;
case "channel":
/* EDIT BY MR
if (args != null) {
ChannelCreateActivity channel = new ChannelCreateActivity(args);
if (actionBarLayout.addFragmentToStack(channel)) {
channel.restoreSelfArgs(savedInstanceState);
}
}
*/
break;
case "edit":
/* EDIT BY MR
if (args != null) {
ChannelEditActivity channel = new ChannelEditActivity(args);
if (actionBarLayout.addFragmentToStack(channel)) {
channel.restoreSelfArgs(savedInstanceState);
}
}
*/
break;
case "chat_profile":
if (args != null) {
@@ -1750,6 +1756,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
@SuppressWarnings("unchecked")
public void didReceivedNotification(int id, Object... args) {
if (id == NotificationCenter.appDidLogout) {
/* EDIT BY MR
if (drawerLayoutAdapter != null) {
drawerLayoutAdapter.notifyDataSetChanged();
}
@@ -1771,6 +1778,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
startActivity(intent2);
onFinish();
finish();
*/
} else if (id == NotificationCenter.closeOtherAppActivities) {
if (args[0] != this) {
onFinish();
@@ -1941,12 +1949,14 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
} else if (lastFragment instanceof ProfileActivity && ((ProfileActivity) lastFragment).isChat() && args != null) {
outState.putBundle("args", args);
outState.putString("fragment", "chat_profile");
/* EDIT BY MR
} else if (lastFragment instanceof ChannelCreateActivity && args != null && args.getInt("step") == 0) {
outState.putBundle("args", args);
outState.putString("fragment", "channel");
} else if (lastFragment instanceof ChannelEditActivity && args != null) {
outState.putBundle("args", args);
outState.putString("fragment", "edit");
*/
}
lastFragment.saveSelfArgs(outState);
}
@@ -1150,8 +1150,10 @@ public class PopupNotificationActivity extends Activity implements NotificationC
@Override
public void didReceivedNotification(int id, Object... args) {
if (id == NotificationCenter.appDidLogout) {
/* EDIT BY MR
onFinish();
finish();
*/
} else if (id == NotificationCenter.pushMessagesUpdated) {
getNewMessage();
} else if (id == NotificationCenter.updateInterfaces) {
@@ -201,7 +201,9 @@ public class PrivacySettingsActivity extends BaseFragment implements Notificatio
} else if (i == groupsRow) {
presentFragment(new PrivacyControlActivity(true));
} else if (i == passwordRow) {
/* EDIT BY MR
presentFragment(new TwoStepVerificationActivity(0));
*/
} else if (i == passcodeRow) {
if (UserConfig.passcodeHash.length() > 0) {
presentFragment(new PasscodeActivity(2));
@@ -445,11 +445,13 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
args.putInt("chat_id", chat_id);
presentFragment(new ChangeChatNameActivity(args));
} else if (id == edit_channel) {
/* EDIT BY MR
Bundle args = new Bundle();
args.putInt("chat_id", chat_id);
ChannelEditActivity fragment = new ChannelEditActivity(args);
fragment.setInfo(info);
presentFragment(fragment);
*/
} else if (id == invite_to_group) {
final TLRPC.User user = MessagesController.getInstance().getUser(user_id);
if (user == null) {
@@ -650,6 +652,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
} else if (position == leaveChannelRow) {
leaveChatPressed();
} else if (position == membersRow || position == blockedUsersRow || position == managementRow) {
/* EDIT BY MR
Bundle args = new Bundle();
args.putInt("chat_id", chat_id);
if (position == blockedUsersRow) {
@@ -660,6 +663,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
args.putInt("type", 2);
}
presentFragment(new ChannelUsersActivity(args));
*/
} else if (position == convertRow) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setMessage(LocaleController.getString("ConvertGroupAlert", R.string.ConvertGroupAlert));
@@ -120,7 +120,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
private int overscrollRow;
private int emptyRow;
private int numberSectionRow;
private int numberRow;
//private int numberRow; -- EDIT BY MR
private int usernameRow;
private int settingsSectionRow;
private int settingsSectionRow2;
@@ -237,7 +237,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
overscrollRow = rowCount++;
emptyRow = rowCount++;
numberSectionRow = rowCount++;
numberRow = rowCount++;
//numberRow = rowCount++; -- EDIT BY MR
usernameRow = rowCount++;
settingsSectionRow = rowCount++;
settingsSectionRow2 = rowCount++;
@@ -322,7 +322,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
MessagesController.getInstance().performLogout(true);
//MessagesController.getInstance().performLogout(true); // EDIT BY MR
}
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
@@ -641,8 +641,10 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
showDialog(builder.create());
} else if (i == usernameRow) {
presentFragment(new ChangeUsernameActivity());
/* EDIT BY MR
} else if (i == numberRow) {
presentFragment(new ChangePhoneHelpActivity());
*/
} else if (i == stickersRow) {
presentFragment(new StickersActivity());
} else if (i == cacheRow) {
@@ -1187,7 +1189,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
@Override
public boolean isEnabled(int i) {
return i == textSizeRow || i == enableAnimationsRow || i == notificationRow || i == backgroundRow || i == numberRow ||
return i == textSizeRow || i == enableAnimationsRow || i == notificationRow || i == backgroundRow /*|| i == numberRow*/ ||
/* EDIT BY MR i == askQuestionRow ||*/ i == sendLogsRow || i == sendByEnterRow || i == autoplayGifsRow || i == privacyRow || i == wifiDownloadRow ||
i == mobileDownloadRow || i == clearLogsRow || i == roamingDownloadRow || i == languageRow || i == usernameRow ||
i == switchBackendButtonRow || i == telegramFaqRow || i == contactsSortRow || i == contactsReimportRow || i == saveToGalleryRow ||
@@ -1406,6 +1408,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
text = LocaleController.getString("NoMediaAutoDownload", R.string.NoMediaAutoDownload);
}
textCell.setTextAndValue(value, text, true);
/* EDIT BY MR
} else if (i == numberRow) {
TLRPC.User user = UserConfig.getCurrentUser();
String value;
@@ -1415,6 +1418,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
value = LocaleController.getString("NumberUnknown", R.string.NumberUnknown);
}
textCell.setTextAndValue(value, LocaleController.getString("Phone", R.string.Phone), true);
*/
} else if (i == usernameRow) {
TLRPC.User user = UserConfig.getCurrentUser();
String value;
@@ -1442,7 +1446,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
return 2;
} else if (i == versionRow) {
return 5;
} else if (i == wifiDownloadRow || i == mobileDownloadRow || i == roamingDownloadRow || i == numberRow || i == usernameRow) {
} else if (i == wifiDownloadRow || i == mobileDownloadRow || i == roamingDownloadRow /*|| i == numberRow EDIT BY MR*/ || i == usernameRow) {
return 6;
} else if (i == settingsSectionRow2 || i == messagesSectionRow2 || i == supportSectionRow2 || i == numberSectionRow || i == mediaDownloadSection2) {
return 4;