use of com.applozic.mobicomkit.api.account.user.MobiComUserPreference in project Applozic-Android-SDK by AppLozic.
the class MainActivity method onNavigationDrawerItemSelected.
@Override
public void onNavigationDrawerItemSelected(int position) {
if (position == 1) {
Intent intent = new Intent(this, ConversationActivity.class);
if (ApplozicClient.getInstance(this).isContextBasedChat()) {
intent.putExtra(ConversationUIService.CONTEXT_BASED_CHAT, true);
}
startActivity(intent);
return;
}
/*
if (position == 1) {
ConversationFragment conversationFragment = new ConversationFragment();
Contact contact = new Contact(this, "mobicomkit");
mTitle = getString(R.string.user_id);
addFragment(this, conversationFragment, "conversationFragment");
conversationFragment.loadConversation(contact);
return;
}*/
if (position == 0) {
mTitle = getString(R.string.ecommerce);
FragmentManager fragmentManager = getSupportFragmentManager();
fragmentManager.beginTransaction().replace(R.id.container, EcommerceFragment.newInstance("", "")).commit();
return;
}
if (position == 2) {
UserLogoutTask.TaskListener userLogoutTaskListener = new UserLogoutTask.TaskListener() {
@Override
public void onSuccess(Context context) {
userLogoutTask = null;
Toast.makeText(getBaseContext(), getBaseContext().getString(R.string.log_out_successful), Toast.LENGTH_SHORT).show();
Intent intent = new Intent(context, LoginActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(intent);
finish();
}
@Override
public void onFailure(Exception exception) {
userLogoutTask = null;
AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
alertDialog.setTitle(getString(R.string.text_alert));
alertDialog.setMessage(exception.toString());
alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, getString(R.string.ok_alert), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
if (!isFinishing()) {
alertDialog.show();
}
}
};
userLogoutTask = new UserLogoutTask(userLogoutTaskListener, this);
userLogoutTask.execute((Void) null);
}
if (position == 3) {
Map<String, String> messageMetaData = new HashMap<>();
messageMetaData.put(Message.MetaDataType.KEY.getValue(), Message.MetaDataType.HIDDEN.getValue());
Message message = new Message();
MobiComUserPreference userPreferences = MobiComUserPreference.getInstance(MainActivity.this);
message.setContactIds("android");
message.setTo("android");
message.setContentType(Message.ContentType.CUSTOM.getValue());
message.setMessage("this is meta data hidden");
message.setMetadata(messageMetaData);
message.setStoreOnDevice(Boolean.TRUE);
message.setRead(Boolean.TRUE);
message.setCreatedAtTime(System.currentTimeMillis() + userPreferences.getDeviceTimeOffset());
message.setSendToDevice(Boolean.FALSE);
message.setType(Message.MessageType.MT_OUTBOX.getValue());
message.setDeviceKeyString(userPreferences.getDeviceKeyString());
message.setSource(Message.Source.MT_MOBILE_APP.getValue());
new MobiComConversationService(MainActivity.this).sendMessage(message, MessageIntentService.class);
}
FragmentManager fragmentManager = getSupportFragmentManager();
fragmentManager.beginTransaction().replace(R.id.container, PlaceholderFragment.newInstance(position + 1)).commit();
}
use of com.applozic.mobicomkit.api.account.user.MobiComUserPreference in project Applozic-Android-SDK by AppLozic.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
MobiComUserPreference userPreference = MobiComUserPreference.getInstance(this);
if (!userPreference.isRegistered()) {
Intent intent = new Intent(this, LoginActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(intent);
finish();
return;
}
mNavigationDrawerFragment = (NavigationDrawerFragment) getSupportFragmentManager().findFragmentById(R.id.navigation_drawer);
mTitle = getTitle();
// Set up the drawer.
mNavigationDrawerFragment.setUp(R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout));
// Put Support Contact Data
buildSupportContactData();
/*else {
Intent intent = new Intent(this, ConversationActivity.class);
startActivity(intent);
}*/
/*ApplozicSetting.getInstance(this).setColor(ApplozicSetting.CUSTOM_MESSAGE_BACKGROUND_COLOR, Color.parseColor("#FFB3E5FC"));
Message message = new Message("contact@applozic.com", "hey! here's a match <3");
new MobiComMessageService(this, MessageIntentService.class).sendCustomMessage(message);*/
}
use of com.applozic.mobicomkit.api.account.user.MobiComUserPreference in project Applozic-Android-SDK by AppLozic.
the class ApplozicClient method isNotAllowed.
public boolean isNotAllowed() {
MobiComUserPreference pref = MobiComUserPreference.getInstance(context);
boolean isDebuggable = (0 != (context.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE));
return !isDebuggable && (pref.getPricingPackage() == RegistrationResponse.PricingType.CLOSED.getValue() || pref.getPricingPackage() == RegistrationResponse.PricingType.BETA.getValue());
}
use of com.applozic.mobicomkit.api.account.user.MobiComUserPreference in project Applozic-Android-SDK by AppLozic.
the class ApplozicMqttService method typingStopped.
public void typingStopped(Contact contact, Channel channel) {
String currentId;
if (channel != null) {
currentId = String.valueOf(channel.getKey());
} else {
currentId = contact.getUserId();
}
MobiComUserPreference mobiComUserPreference = MobiComUserPreference.getInstance(context);
publishTopic(getApplicationKey(context), "0", mobiComUserPreference.getUserId(), currentId);
}
use of com.applozic.mobicomkit.api.account.user.MobiComUserPreference in project Applozic-Android-SDK by AppLozic.
the class ApplozicMqttService method subscribeToTypingTopic.
public synchronized void subscribeToTypingTopic(Channel channel) {
try {
String currentId = null;
if (channel != null) {
currentId = String.valueOf(channel.getKey());
} else {
MobiComUserPreference mobiComUserPreference = MobiComUserPreference.getInstance(context);
currentId = mobiComUserPreference.getUserId();
}
final MqttClient client = connect();
if (client == null || !client.isConnected()) {
return;
}
client.subscribe("typing-" + getApplicationKey(context) + "-" + currentId, 0);
Utils.printLog(context, TAG, "Subscribed to topic: " + "typing-" + getApplicationKey(context) + "-" + currentId);
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations