private void setSearchIcons(SearchView mSearchView) { try { Java.Lang.Reflect.Field searchField = mSearchView.Class.GetDeclaredField("mSearchButton"); searchField.Accessible = true; ImageView searchBtn = (ImageView)searchField.Get(mSearchView); searchBtn.Background = null; searchBtn.SetImageResource(Resource.Drawable.search123); searchBtn.SetScaleType(ImageView.ScaleType.FitCenter); //searchBtn.LayoutParameters.Width = 80; //searchBtn.LayoutParameters.Height = 80; searchBtn.RequestLayout(); searchField = mSearchView.Class.GetDeclaredField("mSearchPlate"); searchField.Accessible = true; LinearLayout searchPlate = (LinearLayout)searchField.Get(mSearchView); ImageView closeBtn = ((ImageView)searchPlate.GetChildAt(1)); closeBtn.SetImageResource(Resource.Drawable.closed); closeBtn.SetScaleType(ImageView.ScaleType.FitCenter); //closeBtn.LayoutParameters.Width = 80; //closeBtn.LayoutParameters.Height = 80; closeBtn.RequestLayout(); //searchPlate.SetBackgroundResource(Resource.Drawable.SearchPlate); //searchPlate.LayoutParameters.Height = 1; int searchPlateId = mSearchView.Context.Resources.GetIdentifier("android:id/search_plate", null, null); EditText plate = (EditText)mSearchView.FindViewById(searchPlateId); //plate.SetBackgroundColor(Color.White); plate.SetTextColor(Color.White); int voiceSearchPlateId = mSearchView.Context.Resources.GetIdentifier("android:id/submit_area", null, null); mSearchView.FindViewById(voiceSearchPlateId).SetBackgroundResource(Resource.Drawable.rounded_textview); // change hint color int searchTextViewId = mSearchView.Context.Resources.GetIdentifier("android:id/search_src_text", null, null); TextView searchTextView = (TextView)mSearchView.FindViewById(searchTextViewId); searchTextView.SetHintTextColor(Resources.GetColor(Color.LightGray)); } catch (Exception ex) { string dst = "sdfsfs"; CustomLogger.CustomLog("From Activity: " + bitopiApplication.CurrentActivity + "\nMessage: " + ex.Message + "\nStack Trace: " + ex.StackTrace + "\n\n", "", bitopiApplication.User != null ? bitopiApplication.User.UserName : ""); } }
private static void writeInstallationFile() { try { //string path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments); //Android.OS.Environment.ExternalStorageDirectory.AbsolutePath; //string documents = System.IO.Path.Combine(Android.OS.Environment.ExternalStorageDirectory.AbsolutePath, "BITOPIUID"); string documents = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData); string filename = Path.Combine(documents, "BITOPIUID"); string path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData); using (var streamWriter = new StreamWriter(filename, false)) { streamWriter.WriteLine(UUID.RandomUUID().ToString().Replace(System.Environment.NewLine, "").Trim()); } } catch (Exception ex) { string s = ex.Message; CustomLogger.CustomLog("From Activity: " + BitopiSingelton.Instance.CurrentActivity + "\nMessage: " + ex.Message + "\nStack Trace: " + ex.StackTrace + "\n\n", "", BitopiSingelton.Instance.User != null ? BitopiSingelton.Instance.User.UserName : ""); } }
public static String id(Context context) { if (sID == null || sID == String.Empty) { //Java.IO.File installation = new Java.IO.File(context.FilesDir, INSTALLATION); //var documents = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments); //string documents = System.IO.Path.Combine(Android.OS.Environment.ExternalStorageDirectory.AbsolutePath, "BITOPIUID"); string folder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData); var documents = System.IO.Path.Combine(folder, ""); if (!System.IO.File.Exists(documents)) { Java.IO.File dir = new Java.IO.File(documents); //bool test = dir.Mkdir(); } var filename = System.IO.Path.Combine(documents, INSTALLATION); try { //var documents = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments); //var filepath = System.IO.Path.Combine(documents, INSTALLATION); //if (!installation.Exists()) if (!System.IO.File.Exists(filename)) { //writeInstallationFile(installation); writeInstallationFile(); } //sID = readInstallationFile(installation); sID = readInstallationFile(); } catch (Exception ex) { //string s = e.Message; CustomLogger.CustomLog("From Activity: " + BitopiSingelton.Instance.CurrentActivity + "\nMessage: " + ex.Message + "\nStack Trace: " + ex.StackTrace + "\n\n", "", BitopiSingelton.Instance.User != null ? BitopiSingelton.Instance.User.UserName : ""); } } sID = sID.Replace(System.Environment.NewLine, "").Trim(); return(sID); }
protected override void OnCreate(Bundle savedInstanceState) { bitopiApplication = (BitopiApplication)this.ApplicationContext; //BitopiSingelton.Instance.CurrentActivity = "Startup Activity"; bitopiApplication.CurrentActivity = "Startup Activity"; base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.layout_startup); tvMsg = FindViewById <TextView>(Resource.Id.tvMsg); tvMsg.Visibility = ViewStates.Gone; webView = (WebView)FindViewById(Resource.Id.wvLoader); webView.SetInitialScale(1); webView.Settings.JavaScriptEnabled = true; webView.Settings.LoadWithOverviewMode = true; webView.Settings.UseWideViewPort = true; webView.Settings.SetLayoutAlgorithm(WebSettings.LayoutAlgorithm.SingleColumn); webView.ScrollBarStyle = ScrollbarStyles.OutsideOverlay; webView.ScrollbarFadingEnabled = false; webView.LoadUrl("file:///android_asset/loading/loader.html"); WifiManager wifiMan = (WifiManager)this.GetSystemService(Context.WifiService); WifiInfo wifiInf = wifiMan.ConnectionInfo; //BitopiSingelton.Instance.MacAddress= UID.id(this); //bitopiApplication.MacAddress = UID.id(this); PushNotificationSingleton.Instance.SaveNotification(""); //BitopiSingelton.Instance.CurrentVersion = this.PackageManager.GetPackageInfo(this.PackageName, // Android.Content.PM.PackageInfoFlags.MetaData).VersionName; bitopiApplication.CurrentVersion = this.PackageManager.GetPackageInfo(this.PackageName, Android.Content.PM.PackageInfoFlags.MetaData).VersionCode; //StartService(new Intent(this, typeof(BitopiRegistrationIntentService))); //StartService(new Intent(this, typeof(BitopiInstanceIDListenerService))); //StartService(new Intent(this, typeof(BitopiGcmListenerService))); //StartService(new Intent(this, typeof(BitopiNotification))); StartService(new Intent(this, typeof(BitopiNotificationService))); AppDomain.CurrentDomain.UnhandledException += (s, e) => { try { typeof(System.Exception).GetField("stack_trace", BindingFlags.NonPublic | BindingFlags.Instance) .SetValue(e.ExceptionObject, null); throw new Exception("CurrentDomainOnUnhandledException", e.ExceptionObject as Exception); } catch (Exception ex) { string str = ex.Message; CustomLogger.VersionName = bitopiApplication.CurrentVersion; CustomLogger.CustomLog("From Activity: " + bitopiApplication.CurrentActivity + "\nMessage: " + ex.Message + "\nStack Trace: " + ex.StackTrace + "\n\n", "", bitopiApplication.User != null ? bitopiApplication.User.UserName : ""); } }; AndroidEnvironment.UnhandledExceptionRaiser += delegate(object sender, RaiseThrowableEventArgs args) { try { typeof(System.Exception).GetField("stack_trace", BindingFlags.NonPublic | BindingFlags.Instance) .SetValue(args.Exception, null); args.Handled = true; throw args.Exception; } catch (Exception ex) { string s = ex.Message; CustomLogger.VersionName = bitopiApplication.CurrentVersion; CustomLogger.CustomLog("From Activity: " + bitopiApplication.CurrentActivity + "\nMessage: " + ex.Message + "\nStack Trace: " + ex.StackTrace + "\n\n", "", bitopiApplication.User != null ? bitopiApplication.User.UserName : ""); } }; }
protected async override void OnStart() { base.OnStart(); webView.Visibility = ViewStates.Gone; try { try { CrossBadge.Current.ClearBadge(); } catch { } if (!bitopiApplication.IsInternetConnectionAvailable(this)) { webView.Visibility = ViewStates.Gone; tvMsg.Visibility = ViewStates.Visible; tvMsg.Text = "No Internet Connection Available."; return; } ISharedPreferences pref = Application.Context.GetSharedPreferences("_bitopi_UserInfo", FileCreationMode.Private); ISharedPreferences prefToken = Application.Context.GetSharedPreferences("_bitopi_DeviceToken", FileCreationMode.Private); string UserName = pref.GetString("UserName", String.Empty); string Password = pref.GetString("Password", String.Empty); string Token = prefToken.GetString("Token", String.Empty); AccountRepository repo = new AccountRepository(ShowLoader, HideLoader); //if (repo.GetVersion() > bitopiApplication.CurrentVersion) //{ // webView.Visibility = ViewStates.Gone; // BitopiSingelton.Instance.ShowNewVersionDialog(this); // return; //} Intent i = new Intent(this, typeof(LoginActivity)); if (String.IsNullOrEmpty(UserName)) { i = new Intent(this, typeof(LoginActivity)); } else { if (String.IsNullOrEmpty(Token)) { bitopiApplication.MacAddress = Guid.NewGuid().ToString(); prefToken.Edit().PutString("Token", bitopiApplication.MacAddress).Commit(); } else { bitopiApplication.MacAddress = Token; } UserModel user = await repo.getUser(UserName, Password, bitopiApplication.MacAddress, bitopiApplication.MacAddress, bitopiApplication.DeviceName, "android", 1, bitopiApplication.CurrentVersion); if (!String.IsNullOrEmpty(user.UserCode)) { bitopiApplication.User = user; pref.Edit().PutString("UserCode", user.UserCode).Commit(); i = new Intent(this, typeof(BitopiActivity)); } else { i = new Intent(this, typeof(LoginActivity)); } } StartActivity(i); } catch (Exception ex) { tvMsg.Visibility = ViewStates.Visible; tvMsg.Text = "The application has encountered an unknown error."; CustomLogger.VersionName = bitopiApplication.CurrentVersion; CustomLogger.CustomLog("From Activity: " + BitopiSingelton.Instance.CurrentActivity + "\nMessage: " + ex.Message + "\nStack Trace: " + ex.StackTrace + "\n\n", "", BitopiSingelton.Instance.User != null ? BitopiSingelton.Instance.User.UserName : ""); } }
void SendNotification(BitopiGcmMessage gcmMsg) { try { string title = "", msgBody = ""; // TytMoblieApplication application = (TytMoblieApplication)this.ApplicationContext; //BitopiGcmMessage gcmMsg = JsonConvert.DeserializeObject<BitopiGcmMessage>(message); string approvalName = gcmMsg.Approval == "1" ? "PO" : gcmMsg.Approval == "4" ? "Cash Requisition" : ""; int requestID = Convert.ToInt16(gcmMsg.Approval); if (BitopiSingelton.Instance.ReceivingMessages.ContainsKey(gcmMsg.Approval)) { BitopiSingelton.Instance.ReceivingMessages[gcmMsg.Approval].Add(gcmMsg.POID); msgBody = "You have " + BitopiSingelton.Instance.ReceivingMessages[gcmMsg.Approval].Count() + " " + approvalName + " to " + gcmMsg.ApprovalType; } else { BitopiSingelton.Instance.ReceivingMessages.Add(gcmMsg.Approval, new List <string> { gcmMsg.POID }); msgBody = "You have 1 " + approvalName + " to " + gcmMsg.ApprovalType; } ApprovalRepository repo = new ApprovalRepository(); int result = repo.ReceiveNotification(BitopiSingelton.Instance.User.UserCode, BitopiSingelton.Instance.MacAddress, (ApprovalType)Convert.ToInt32(gcmMsg.Approval), gcmMsg.ApprovalName, gcmMsg.POID).Result; gcmMsg = new BitopiGcmMessage(); //ISharedPreferences sp = PreferenceManager.GetDefaultSharedPreferences(this); //string employeeid = sp.GetString("employeeid_id", ""); gcmMsg.DateCreated = DateTime.Now; Intent intent; intent = new Intent(this, typeof(StartupActivity)); intent.AddFlags(ActivityFlags.ClearTop); var pendingIntent = PendingIntent.GetActivity(ApplicationContext, requestID, intent, 0); //requestID = DateTime.Now.Millisecond; var notificationBuilder = new NotificationCompat.Builder(this) .SetSmallIcon(BitopiApprovalSystem.Resource.Drawable.bitopiLogo) .SetContentTitle("Bitopi Approval System") .SetContentText(msgBody) .SetAutoCancel(true) .SetContentIntent(pendingIntent) .SetDefaults(NotificationCompat.DefaultSound); var notificationManager = (NotificationManager)GetSystemService(Context.NotificationService); //new UserRepository().GetNotificationCacheAsCompleted(gcmMsg.NotificationExecId); notificationManager.Notify(requestID, notificationBuilder.Build()); } catch (Exception ex) { CustomLogger.CustomLog("From Activity: " + BitopiSingelton.Instance.CurrentActivity + "\nMessage: " + ex.Message + "\nStack Trace: " + ex.StackTrace + "\n\n", "", BitopiSingelton.Instance.User != null ? BitopiSingelton.Instance.User.UserName : ""); } }
/** * Override {@link #getChildView(int, int, bool, View, ViewGroup)} instead. */ public override View GetChildView(int groupPosition, int childPosition, bool isLastChild, View convertView, ViewGroup parent) { try { GroupInfo info = getGroupInfo(groupPosition); info.ChildViewCallCount += 1;; if (info.animating) { // If this group is animating, return the a DummyView... if (convertView is DummyView == false) { convertView = new DummyView(parent.Context); convertView.LayoutParameters = new AbsListView.LayoutParams(LayoutParams.MatchParent, 0); } if (childPosition < info.firstChildPosition) { // The reason why we do this is to support the collapse // this group when the group view is not visible but the // children of this group are. When notifyDataSetChanged // is called, the ExpandableListView tries to keep the // list position the same by saving the first visible item // and jumping back to that item after the views have been // refreshed. Now the problem is, if a group has 2 items // and the first visible item is the 2nd child of the group // and this group is collapsed, then the dummy view will be // used for the group. But now the group only has 1 item // which is the dummy view, thus when the ListView is trying // to restore the scroll position, it will try to jump to // the second item of the group. But this group no longer // has a second item, so it is forced to jump to the next // group. This will cause a very ugly visual glitch. So // the way that we counteract this is by creating as many // dummy views as we need to maintain the scroll position // of the ListView after notifyDataSetChanged has been // called. convertView.LayoutParameters.Height = 0; return(convertView); } AnimatedExpandableListView listView = (AnimatedExpandableListView)parent; DummyView dummyView = (DummyView)convertView; // Clear the views that the dummy view draws. dummyView.clearViews(); // Set the style of the divider dummyView.setDivider(listView.Divider, parent.MeasuredWidth, listView.DividerHeight); // Make measure specs to measure child views int measureSpecW = MeasureSpec.MakeMeasureSpec(parent.Width, MeasureSpecMode.Exactly); int measureSpecH = MeasureSpec.MakeMeasureSpec(0, MeasureSpecMode.Unspecified); int totalHeight = 0; int clipHeight = parent.Height; int len = getRealChildrenCount(groupPosition); for (int i = info.firstChildPosition; i < len; i++) { View childView = getRealChildView(groupPosition, i, (i == len - 1), null, parent); LayoutParams p = (LayoutParams)childView.LayoutParameters; if (p == null) { p = (AbsListView.LayoutParams)generateDefaultLayoutParams(); childView.LayoutParameters = p; } int lpHeight = p.Height; int childHeightSpec; if (lpHeight > 0) { childHeightSpec = MeasureSpec.MakeMeasureSpec(lpHeight, MeasureSpecMode.Exactly); } else { childHeightSpec = measureSpecH; } childView.Measure(measureSpecW, childHeightSpec); totalHeight += childView.MeasuredHeight; if (totalHeight < clipHeight) { // we only need to draw enough views to fool the user... dummyView.addFakeView(childView); } else { dummyView.addFakeView(childView); // if this group has too many views, we don't want to // calculate the height of everything... just do a light // approximation and break int averageHeight = totalHeight / (i + 1); totalHeight += (len - i - 1) * averageHeight; break; } } object o = dummyView.Tag; Java.Lang.Number state = o == null ? STATE_IDLE : (Java.Lang.Number)o; if (info.expanding && state != STATE_EXPANDING && info.ChildViewCallCount <= 1) //&& info.ChildViewCallCount<=1 { //new System.Threading.Thread(new System.Threading.ThreadStart(delegate //{ // _activity.RunOnUiThread(() => //{ ExpandAnimation ani = new ExpandAnimation(dummyView, 0, totalHeight, info, _activity, this); ani.Duration = this.parent.getAnimationDuration(); //ani.SetInterpolator(_activity, Android.Resource.Animation.LinearInterpolator); ani.Interpolator = new AccelerateDecelerateInterpolator(); ani.SetAnimationListener(new CustomAnimateListener(STATE_EXPANDING, groupPosition, dummyView, info, listView, this, listView.OnAnimationEnd)); //ani.FillAfter = false; dummyView.StartAnimation(ani); //ani.RepeatCount = Animation.StartOnFirstFrame; /*****************Another Animation Implementation***************** * ValueAnimator animator = ValueAnimator.OfInt(0, totalHeight); * animator.SetDuration(this.parent.getAnimationDuration()); * animator.SetInterpolator(new AccelerateDecelerateInterpolator()); * * animator.Update += (object sender, ValueAnimator.AnimatorUpdateEventArgs e) => * { * * * var value = (int)animator.AnimatedValue; * if (factor != value) * { * factor = value; * ViewGroup.LayoutParams layoutParams = dummyView.LayoutParameters; * layoutParams.Height = value; * dummyView.LayoutParameters = layoutParams; * Console.System.Diagnostics.Debug.WriteLine("Value: " + value.ToString()); * } * * }; * animator.AddListener(new CustomAnimateListener(STATE_EXPANDING, groupPosition, dummyView, info, listView, this)); * * ************************/ dummyView.Tag = STATE_EXPANDING; // }); //})).Start(); } else if (!info.expanding && state != STATE_COLLAPSING && info.ChildViewCallCount <= 1) //&& info.ChildViewCallCount<=1 { if (info.dummyHeight == -1) { info.dummyHeight = totalHeight; } //new System.Threading.Thread(new System.Threading.ThreadStart(delegate //{ // _activity.RunOnUiThread(() => //{ ExpandAnimation ani = new ExpandAnimation(dummyView, info.dummyHeight, 0, info, _activity, this); ani.Duration = this.parent.getAnimationDuration(); //ani.SetInterpolator(_activity, Android.Resource.Animation.AccelerateInterpolator); ani.Interpolator = new AccelerateDecelerateInterpolator(); ani.SetAnimationListener(new CustomAnimateListener(STATE_COLLAPSING, groupPosition, dummyView, info, listView, this, listView.OnAnimationEnd)); long i = ani.ComputeDurationHint(); dummyView.StartAnimation(ani); /**********************************Another animation implementation******************** * ValueAnimator animator = ValueAnimator.OfInt(totalHeight, 0); * animator.SetDuration(this.parent.getAnimationDuration()); * animator.SetInterpolator(new AccelerateDecelerateInterpolator()); * animator.Update += (object sender, ValueAnimator.AnimatorUpdateEventArgs e) => * { * var value = (int)animator.AnimatedValue; * if (factor != value) * { * factor = value; * ViewGroup.LayoutParams layoutParams = dummyView.LayoutParameters; * layoutParams.Height = value; * dummyView.LayoutParameters = layoutParams; * Console.System.Diagnostics.Debug.WriteLine("Value: " + value.ToString()); * } * }; * animator.AddListener(new CustomAnimateListener(STATE_COLLAPSING,groupPosition,dummyView,info,listView,this)); * animator.Start(); * ****************************************/ dummyView.Tag = STATE_COLLAPSING; // }); //})).Start(); } return(convertView); } else { info.ChildViewCallCount = 0; return(getRealChildView(groupPosition, childPosition, isLastChild, convertView, parent)); } } catch (System.Exception ex) { string s = ex.Message; CustomLogger.CustomLog("From Activity: " + BitopiSingelton.Instance.CurrentActivity + "\nMessage: " + ex.Message + "\nStack Trace: " + ex.StackTrace + "\n\n", "", BitopiSingelton.Instance.User != null ? BitopiSingelton.Instance.User.UserName : ""); return(null); } }
protected override void OnCreate(Bundle savedInstanceState) { bitopiApplication = (BitopiApplication)this.ApplicationContext; //BitopiSingelton.Instance.CurrentActivity = "Startup Activity"; bitopiApplication.CurrentActivity = "Startup Activity"; base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.layout_startup); SupportActionBar.SetDisplayShowCustomEnabled(true); SupportActionBar.SetCustomView(Resource.Layout.custom_actionbar); tvMsg = FindViewById <TextView>(Resource.Id.tvMsg); tvMsg.Visibility = ViewStates.Gone; FindViewById <ImageButton>(Resource.Id.btnDrawermenu).Visibility = ViewStates.Gone; WifiManager wifiMan = (WifiManager)this.GetSystemService(Context.WifiService); WifiInfo wifiInf = wifiMan.ConnectionInfo; //BitopiSingelton.Instance.MacAddress= UID.id(this); //bitopiApplication.MacAddress = UID.id(this); PushNotificationSingleton.Instance.SaveNotification(""); //BitopiSingelton.Instance.CurrentVersion = this.PackageManager.GetPackageInfo(this.PackageName, // Android.Content.PM.PackageInfoFlags.MetaData).VersionName; bitopiApplication.CurrentVersion = this.PackageManager.GetPackageInfo(this.PackageName, Android.Content.PM.PackageInfoFlags.MetaData).VersionCode; //StartService(new Intent(this, typeof(BitopiRegistrationIntentService))); //StartService(new Intent(this, typeof(BitopiInstanceIDListenerService))); //StartService(new Intent(this, typeof(BitopiGcmListenerService))); //StartService(new Intent(this, typeof(BitopiNotification))); StartService(new Intent(this, typeof(BitopiNotificationService))); AppDomain.CurrentDomain.UnhandledException += (s, e) => { try { typeof(System.Exception).GetField("stack_trace", BindingFlags.NonPublic | BindingFlags.Instance) .SetValue(e.ExceptionObject, null); throw new Exception("CurrentDomainOnUnhandledException", e.ExceptionObject as Exception); } catch (Exception ex) { string str = ex.Message; CustomLogger.VersionName = bitopiApplication.CurrentVersion; CustomLogger.CustomLog("From Activity: " + bitopiApplication.CurrentActivity + "\nMessage: " + ex.Message + "\nStack Trace: " + ex.StackTrace + "\n\n", "", bitopiApplication.User != null ? bitopiApplication.User.UserName : ""); } }; AndroidEnvironment.UnhandledExceptionRaiser += delegate(object sender, RaiseThrowableEventArgs args) { try { typeof(System.Exception).GetField("stack_trace", BindingFlags.NonPublic | BindingFlags.Instance) .SetValue(args.Exception, null); args.Handled = true; throw args.Exception; } catch (Exception ex) { string s = ex.Message; CustomLogger.VersionName = bitopiApplication.CurrentVersion; CustomLogger.CustomLog("From Activity: " + bitopiApplication.CurrentActivity + "\nMessage: " + ex.Message + "\nStack Trace: " + ex.StackTrace + "\n\n", "", bitopiApplication.User != null ? bitopiApplication.User.UserName : ""); } }; }