1 package com.asimplesock.chatistics; 2 3 import android.annotation.SuppressLint; 4 import android.content.ActivityNotFoundException; 5 import android.content.Intent; 6 import android.content.SharedPreferences; 7 import android.graphics.Bitmap; 8 import android.graphics.Canvas; 9 import android.media.MediaPlayer; 10 import android.net.Uri; 11 import android.os.AsyncTask; 12 import android.os.Build; 13 import android.os.Bundle; 14 import android.os.Handler; 15 import android.provider.MediaStore; 16 import android.util.DisplayMetrics; 17 import android.view.LayoutInflater; 18 import android.view.View; 19 import android.view.ViewTreeObserver; 20 import android.view.animation.AnimationUtils; 21 import android.widget.Button; 22 import android.widget.ImageView; 23 import android.widget.LinearLayout; 24 import android.widget.MediaController; 25 import android.widget.ProgressBar; 26 import android.widget.RelativeLayout; 27 import android.widget.TextView; 28 import android.widget.Toast; 29 import android.widget.VideoView; 30 31 import androidx.annotation.RequiresApi; 32 import androidx.appcompat.app.AppCompatActivity; 33 import androidx.constraintlayout.widget.ConstraintLayout; 34 import androidx.core.widget.NestedScrollView; 35 36 import com.github.mikephil.charting.charts.BarChart; 37 import com.github.mikephil.charting.components.XAxis; 38 import com.github.mikephil.charting.components.YAxis; 39 import com.github.mikephil.charting.data.BarData; 40 import com.github.mikephil.charting.data.BarDataSet; 41 import com.github.mikephil.charting.data.BarEntry; 42 import com.github.mikephil.charting.formatter.IndexAxisValueFormatter; 43 import com.github.mikephil.charting.interfaces.datasets.IBarDataSet; 44 import com.google.android.play.core.review.ReviewInfo; 45 import com.google.android.play.core.review.ReviewManager; 46 import com.google.android.play.core.review.ReviewManagerFactory; 47 import com.google.android.play.core.tasks.Task; 48 49 import java.io.BufferedReader; 50 import java.io.ByteArrayInputStream; 51 import java.io.IOException; 52 import java.io.InputStream; 53 import java.io.InputStreamReader; 54 import java.net.HttpURLConnection; 55 import java.net.URL; 56 import java.text.ParseException; 57 import java.text.SimpleDateFormat; 58 import java.util.ArrayList; 59 import java.util.Calendar; 60 import java.util.Date; 61 import java.util.List; 62 import java.util.Objects; 63 import java.util.Scanner; 64 import java.util.StringTokenizer; 65 import java.util.concurrent.TimeUnit; 66 import java.util.regex.Matcher; 67 import java.util.regex.Pattern; 68 69 import lecho.lib.hellocharts.gesture.ZoomType; 70 import lecho.lib.hellocharts.model.Axis; 71 import lecho.lib.hellocharts.model.AxisValue; 72 import lecho.lib.hellocharts.model.Column; 73 import lecho.lib.hellocharts.model.ColumnChartData; 74 import lecho.lib.hellocharts.model.Line; 75 import lecho.lib.hellocharts.model.LineChartData; 76 import lecho.lib.hellocharts.model.PieChartData; 77 import lecho.lib.hellocharts.model.PointValue; 78 import lecho.lib.hellocharts.model.SliceValue; 79 import lecho.lib.hellocharts.model.SubcolumnValue; 80 import lecho.lib.hellocharts.model.Viewport; 81 import lecho.lib.hellocharts.view.ColumnChartView; 82 import lecho.lib.hellocharts.view.LineChartView; 83 import lecho.lib.hellocharts.view.PieChartView; 84 85 public class MainActivity extends AppCompatActivity { 86 int lent1 = 0; 87 88 int lent2 = 0; 89 90 String chats = ""; 91 92 boolean single = false; 93 94 boolean singleSharing = false; 95 96 boolean shareAvailable = false; 97 98 String line = ""; 99 100 int viewNum = 0; 101 102 String all = ""; 103 104 Date dater = null; 105 106 int back_color = 0; 107 108 int xAxisPos = 0; 109 110 int activeGraph = 1; 111 112 Line liner = null; 113 114 String firstDate = ""; 115 116 boolean isHowToShown = false; 117 118 int color_one = 0; 119 int color_two = 0; 120 121 String creator = ""; 122 123 boolean hameshaFormat = false; 124 125 boolean neverFormat = false; 126 127 boolean backMode = false; 128 129 130 boolean anotherProcessed = false; 131 132 LineChartData data = new LineChartData(); 133 134 BarData data1 = new BarData(); 135 136 ArrayList<String> xAxisLables = new ArrayList(); 137 138 String name1 = "Name 1"; 139 140 String name2 = "Name 2"; 141 142 int mTexts1 = 0; 143 144 int mTexts2 = 0; 145 146 int mWords1 = 0; 147 148 int mWords2 = 0; 149 150 int ulen1 = 0; 151 152 int ulen2 = 0; 153 154 String[] mEmojiCount1 = new String[900000]; 155 156 String[] mEmojiCount2 = new String[900000]; 157 158 int[] fEmoji1; 159 160 int[] fEmoji2; 161 162 String firstMsg = "First Msg"; 163 164 String lastMsg = "Last Msg"; 165 166 String rName1; 167 168 String rName2; 169 170 boolean processed = true; 171 172 String[] words1 = new String[100]; 173 174 int[] fWords1 = new int[100]; 175 176 String[] words2 = new String[100]; 177 178 int[] fWords2 = new int[100]; 179 180 MoreData moreData = null; 181 182 long DaysBetween = 0L; 183 184 String[] people = new String[256]; 185 186 int[] peopleFreq = new int[256]; 187 188 int members = 0; 189 190 int totalMsgs = 0; 191 192 int streak = 1; 193 194 int current_Streak = 1; 195 196 String streak_ended = ""; 197 198 int days_talked = 0; 199 200 int test = 0; 201 202 Bitmap bm0, bm1, bm2, bm3, bm4, bmNames; 203 204 ArrayList imageUriArray = new ArrayList(); 205 206 boolean dateError = false; 207 208 int minutesSpent = 0; 209 210 private ReviewManager reviewManager; 211 212 @Override 213 protected void onResume() { 214 super.onResume(); 215 SharedPreferences sharedPreferences = getSharedPreferences("data", MODE_PRIVATE); 216 color_one = sharedPreferences.getInt("color_one", getColor(R.color.cyan)); 217 color_two = sharedPreferences.getInt("color_two", getColor(R.color.pinkie)); 218 back_color = sharedPreferences.getInt("back_color", getColor(R.color.colorPrimary)); 219 try { 220 ConstraintLayout constraintLayout = findViewById(R.id.root_splash); 221 constraintLayout.setBackgroundColor(back_color); 222 if (!(color_one == getColor(R.color.cyan) || color_two == getColor(R.color.pinkie))) { 223 Button button = findViewById(R.id.button); 224 Button button1 = findViewById(R.id.textView28); 225 button.setBackgroundColor(color_one); 226 button1.setBackgroundColor(color_one); 227 Button button2 = findViewById(R.id.button2); 228 Button button3 = findViewById(R.id.textView27); 229 button2.setBackgroundColor(color_two); 230 button3.setBackgroundColor(color_two); 231 ConstraintLayout.LayoutParams params = (ConstraintLayout.LayoutParams) button.getLayoutParams(); 232 params.setMargins(16, 48, 16, 24); 233 button.setLayoutParams(params); 234 params = (ConstraintLayout.LayoutParams) button1.getLayoutParams(); 235 params.setMargins(16, 48, 16, 24); 236 button1.setLayoutParams(params); 237 params = (ConstraintLayout.LayoutParams) button2.getLayoutParams(); 238 params.setMargins(16, 48, 16, 24); 239 button2.setLayoutParams(params); 240 params = (ConstraintLayout.LayoutParams) button3.getLayoutParams(); 241 params.setMargins(16, 48, 16, 24); 242 button3.setLayoutParams(params); 243 244 TextView logo_one = findViewById(R.id.logo_one); 245 TextView logo_two = findViewById(R.id.logo_two); 246 logo_one.setBackgroundColor(color_one); 247 logo_two.setBackgroundColor(color_two); 248 } else { 249 setContentView(R.layout.splash_screen); 250 constraintLayout = findViewById(R.id.root_splash); 251 constraintLayout.setBackgroundColor(back_color); 252 } 253 } catch (Exception e) { 254 System.out.println("Resumed to Non Splash Screen"); 255 } 256 } 257 258 protected void onCreate(Bundle savedInstanceState) { 259 super.onCreate(savedInstanceState); 260 setContentView(R.layout.splash_screen); 261 hideStatusBar(); 262 SharedPreferences sharedPreferences = getSharedPreferences("data", MODE_PRIVATE); 263 color_one = sharedPreferences.getInt("color_one", getColor(R.color.cyan)); 264 color_two = sharedPreferences.getInt("color_two", getColor(R.color.pinkie)); 265 back_color = sharedPreferences.getInt("back_color", getColor(R.color.colorPrimary)); 266 if (color_one != getColor(R.color.cyan)) { 267 Button button = findViewById(R.id.button); 268 Button button1 = findViewById(R.id.textView28); 269 button.setBackgroundColor(color_one); 270 button1.setBackgroundColor(color_one); 271 Button button2 = findViewById(R.id.button2); 272 Button button3 = findViewById(R.id.textView27); 273 button2.setBackgroundColor(color_two); 274 button3.setBackgroundColor(color_two); 275 } 276 Intent intent = getIntent(); 277 String action = intent.getAction(); 278 String type = intent.getType(); 279 if ("android.intent.action.SEND_MULTIPLE".equals(action) && type != null && 280 type.startsWith("text/")) { 281 Uri uri = Objects.requireNonNull(intent.getClipData()).getItemAt(0).getUri(); 282 StringBuilder chatContent = new StringBuilder(); 283 try { 284 InputStream inputstream = getContentResolver().openInputStream(uri); 285 byte[] data = new byte[1024]; 286 assert inputstream != null; 287 int bytesRead = inputstream.read(data); 288 while (bytesRead != -1) { 289 chatContent.append(new String(data)); 290 bytesRead = inputstream.read(data); 291 } 292 this.chats = chatContent.toString(); 293 this.all = this.chats; 294 295 if (Build.VERSION.SDK_INT >= 26) { 296 if (parse()) { 297 sharedPreferences = getSharedPreferences("data", MODE_PRIVATE); 298 boolean forceGroup = sharedPreferences.getBoolean("forceGroup", false); 299 if (forceGroup) { 300 Toast.makeText(this, "Turn off Force Group Statistics in Settings to revert back to normal Chatistics", Toast.LENGTH_LONG).show(); 301 } 302 setContentView(R.layout.activity_group); 303 TextView key1 = findViewById(R.id.key1); 304 TextView key2 = findViewById(R.id.key2); 305 TextView key3 = findViewById(R.id.key3); 306 TextView key4 = findViewById(R.id.key4); 307 TextView key5 = findViewById(R.id.key5); 308 TextView textView48 = findViewById(R.id.textView48); 309 TextView textView59 = findViewById(R.id.textView59); 310 TextView textView95 = findViewById(R.id.textView95); 311 TextView textView99 = findViewById(R.id.textView99); 312 TextView textView100 = findViewById(R.id.textView100); 313 TextView textView103 = findViewById(R.id.textView103); 314 TextView legend2 = findViewById(R.id.legend2); 315 TextView legend3 = findViewById(R.id.legend3); 316 TextView legend4 = findViewById(R.id.legend4); 317 TextView legend5 = findViewById(R.id.legend5); 318 /** A better more robust name finder replacing getPeopleAndFrequency **/ 319 // getPeopleAndFrequency(); 320 321 for (int i = 0; i < members; i++) { 322 totalMsgs = totalMsgs + peopleFreq[i]; 323 if (peopleFreq[i] < 25) { 324 peopleFreq[i] = 0; 325 members = i; 326 break; 327 } 328 } 329 330 331 textView59.setText(("" + members)); 332 textView95.setText(("" + totalMsgs)); 333 textView48.setText(getGroupName()); 334 textView99.setText(firstDate); 335 textView100.setText(creator); 336 rName1 = "Group"; 337 name1 = getGroupName(); 338 name2 = people[0]; 339 ColumnChartView columnChartView = findViewById(R.id.columnChartView); 340 int numSubcolumns = 4; 341 int numColumns = 1; 342 // Column can have many subcolumns, here I use 4 subcolumn in each of 8 columns. 343 List<Column> columns = new ArrayList<Column>(); 344 List<SubcolumnValue> values; 345 values = new ArrayList<SubcolumnValue>(); 346 switch (members) { 347 case 1: 348 values.add(new SubcolumnValue(peopleFreq[0], getColor(R.color.Lred))); 349 key1.setText((" " + people[0])); 350 key2.setVisibility(View.GONE); 351 key3.setVisibility(View.GONE); 352 key4.setVisibility(View.GONE); 353 key5.setVisibility(View.GONE); 354 legend2.setVisibility(View.GONE); 355 legend3.setVisibility(View.GONE); 356 legend4.setVisibility(View.GONE); 357 legend5.setVisibility(View.GONE); 358 break; 359 case 2: 360 values.add(new SubcolumnValue(peopleFreq[0], getColor(R.color.Lred))); 361 values.add(new SubcolumnValue(peopleFreq[1], getColor(R.color.Lorange))); 362 key1.setText((" " + people[0].substring(0, people[0].indexOf(' ')))); 363 key2.setText((" " + people[1].substring(0, people[1].indexOf(' ')))); 364 key3.setVisibility(View.GONE); 365 key4.setVisibility(View.GONE); 366 key5.setVisibility(View.GONE); 367 legend3.setVisibility(View.GONE); 368 legend4.setVisibility(View.GONE); 369 legend5.setVisibility(View.GONE); 370 break; 371 case 3: 372 values.add(new SubcolumnValue(peopleFreq[0], getColor(R.color.Lred))); 373 values.add(new SubcolumnValue(peopleFreq[1], getColor(R.color.Lorange))); 374 values.add(new SubcolumnValue(peopleFreq[2], getColor(R.color.Lblue))); 375 key1.setText((" " + people[0])); 376 key2.setText((" " + people[1])); 377 key3.setText((" " + people[2])); 378 key4.setVisibility(View.GONE); 379 key5.setVisibility(View.GONE); 380 legend4.setVisibility(View.GONE); 381 legend5.setVisibility(View.GONE); 382 break; 383 case 4: 384 values.add(new SubcolumnValue(peopleFreq[0], getColor(R.color.Lred))); 385 values.add(new SubcolumnValue(peopleFreq[1], getColor(R.color.Lorange))); 386 values.add(new SubcolumnValue(peopleFreq[2], getColor(R.color.Lblue))); 387 values.add(new SubcolumnValue(peopleFreq[3], getColor(R.color.Lyellow))); 388 key1.setText((" " + people[0])); 389 key2.setText((" " + people[1])); 390 key3.setText((" " + people[2])); 391 key4.setText((" " + people[3])); 392 key5.setVisibility(View.GONE); 393 legend5.setVisibility(View.GONE); 394 break; 395 default: 396 values.add(new SubcolumnValue(peopleFreq[0], getColor(R.color.Lred))); 397 values.add(new SubcolumnValue(peopleFreq[1], getColor(R.color.Lorange))); 398 values.add(new SubcolumnValue(peopleFreq[2], getColor(R.color.Lblue))); 399 values.add(new SubcolumnValue(peopleFreq[3], getColor(R.color.Lyellow))); 400 values.add(new SubcolumnValue(peopleFreq[4], getColor(R.color.Lgreen))); 401 key1.setText((" " + people[0])); 402 key2.setText((" " + people[1])); 403 key3.setText((" " + people[2])); 404 key4.setText((" " + people[3])); 405 key5.setText((" " + people[4])); 406 break; 407 } 408 Column column = new Column(values); 409 column.setHasLabels(true); 410 columns.add(column); 411 columnChartView.setColumnChartData(new ColumnChartData(columns)); 412 413 String date = firstMsg; 414 Scanner sn = new Scanner(this.chats); 415 while (sn.hasNextLine()) { 416 String temp = sn.nextLine(); 417 if (temp.contains(people[0] + ":")) { 418 if (!date.equals(temp.substring(0, this.chats.indexOf(',')))) { 419 if (temp.indexOf(',') != -1) 420 date = temp.substring(0, temp.indexOf(',')); 421 } 422 } 423 if (temp.contains(people[1] + ":")) { 424 if (!date.equals(temp.substring(0, this.chats.indexOf(',')))) { 425 if (temp.indexOf(',') != -1) 426 date = temp.substring(0, temp.indexOf(',')); 427 } 428 } 429 String check = (people[2] + ":"); 430 if (temp.contains(people[2].substring(0, people[2].indexOf(' ')) + ":")) { 431 if (!date.equals(temp.substring(0, this.chats.indexOf(',')))) { 432 if (temp.indexOf(',') != -1) 433 date = temp.substring(0, temp.indexOf(',')); 434 } 435 } 436 } 437 lastMsg = date; 438 @SuppressLint("SimpleDateFormat") SimpleDateFormat myFormat = new SimpleDateFormat("dd/MM/yy"); 439 firstMsg = myFormat.format(new SimpleDateFormat("dd MM yy").parse(firstMsg)); 440 textView103.setText((((1.0 * totalMsgs / getTotalDays()) + " ").substring(0, 5))); 441 } 442 } 443 } catch (Exception e) { 444 e.printStackTrace(); 445 Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show(); 446 } 447 } 448 } 449 450 private boolean parse() { 451 days_talked = 0; 452 SharedPreferences sharedPreferences = getSharedPreferences("data", MODE_PRIVATE); 453 boolean forceGroup = sharedPreferences.getBoolean("forceGroup", false); 454 single = sharedPreferences.getBoolean("single", true); 455 if (singleSharing) 456 single = false; 457 if (forceGroup) { 458 return true; 459 } 460 LayoutInflater inflator = getLayoutInflater(); 461 getWindow().setBackgroundDrawableResource(R.drawable.screen); 462 if (single) { 463 View view = inflator.inflate(R.layout.single, null, false); 464 view.startAnimation(AnimationUtils.loadAnimation(this, R.anim.fadein)); 465 setContentView(view); 466 NestedScrollView nestedScrollView = findViewById(R.id.background_color); 467 468 nestedScrollView.getViewTreeObserver() 469 .addOnScrollChangedListener(new 470 ViewTreeObserver.OnScrollChangedListener() { 471 @Override 472 public void onScrollChanged() { 473 474 if (!nestedScrollView.canScrollVertically(1)) { 475 Handler handler = new Handler(); 476 if (rName1.equals("Sample")!=true) { 477 handler.postDelayed(new Runnable() { 478 public void run() { 479 init(); 480 } 481 }, 5000); 482 } 483 } 484 485 if (!nestedScrollView.canScrollVertically(-1)) { 486 // top of scroll view 487 488 489 } 490 } 491 }); 492 493 ConstraintLayout constraintLayout = findViewById(R.id.layout_result); 494 ConstraintLayout constraintLayout0 = findViewById(R.id.title_bar); 495 ConstraintLayout constraintLayout1 = findViewById(R.id.layout_more); 496 ConstraintLayout constraintLayout2 = findViewById(R.id.layout_additional); 497 BarChart lineChartView = findViewById(R.id.ColumnChartView); 498 ConstraintLayout constraintLayout3 = findViewById(R.id.title_bar_ad); 499 500 constraintLayout.setBackgroundColor(back_color); 501 constraintLayout0.setBackgroundColor(back_color); 502 constraintLayout1.setBackgroundColor(back_color); 503 constraintLayout2.setBackgroundColor(back_color); 504 constraintLayout3.setBackgroundColor(back_color); 505 lineChartView.setBackgroundColor(back_color); 506 507 nestedScrollView.setBackgroundColor(back_color); 508 TextView logo_one = findViewById(R.id.logo_one); 509 TextView logo_two = findViewById(R.id.logo_two); 510 logo_one.setBackgroundColor(color_one); 511 logo_two.setBackgroundColor(color_two); 512 TextView textView5 = findViewById(R.id.textView5); 513 TextView textView7 = findViewById(R.id.textView7); 514 TextView textView8 = findViewById(R.id.textView8); 515 TextView textView12 = findViewById(R.id.textView12); 516 TextView textView24 = findViewById(R.id.textView24); 517 TextView textView29 = findViewById(R.id.textView29); 518 TextView textView39 = findViewById(R.id.textView39); 519 TextView textView40 = findViewById(R.id.textView40); 520 TextView textView42 = findViewById(R.id.textView42); 521 TextView textView43 = findViewById(R.id.textView43); 522 TextView textView = findViewById(R.id.textView); 523 TextView textView11 = findViewById(R.id.textView11); 524 TextView textView30 = findViewById(R.id.textView30); 525 TextView textView34 = findViewById(R.id.textView34); 526 TextView textView38 = findViewById(R.id.textView38); 527 TextView textView41 = findViewById(R.id.textView41); 528 TextView textView35 = findViewById(R.id.textView35); 529 TextView textView44 = findViewById(R.id.textView44); 530 531 textView.setTypeface(getResources().getFont(R.font.chinkala)); 532 textView5.setTypeface(getResources().getFont(R.font.chinkala)); 533 textView7.setTypeface(getResources().getFont(R.font.chinkala)); 534 textView8.setTypeface(getResources().getFont(R.font.chinkala)); 535 textView11.setTypeface(getResources().getFont(R.font.chinkala)); 536 textView12.setTypeface(getResources().getFont(R.font.chinkala)); 537 textView24.setTypeface(getResources().getFont(R.font.chinkala)); 538 textView29.setTypeface(getResources().getFont(R.font.chinkala)); 539 textView30.setTypeface(getResources().getFont(R.font.chinkala)); 540 textView34.setTypeface(getResources().getFont(R.font.chinkala)); 541 textView38.setTypeface(getResources().getFont(R.font.chinkala)); 542 textView39.setTypeface(getResources().getFont(R.font.chinkala)); 543 textView40.setTypeface(getResources().getFont(R.font.chinkala)); 544 textView41.setTypeface(getResources().getFont(R.font.chinkala)); 545 textView42.setTypeface(getResources().getFont(R.font.chinkala)); 546 textView43.setTypeface(getResources().getFont(R.font.chinkala)); 547 textView35.setTypeface(getResources().getFont(R.font.chinkala)); 548 textView44.setTypeface(getResources().getFont(R.font.chinkala)); 549 } else { 550 View view = inflator.inflate(R.layout.activity_result, null, false); 551 view.startAnimation(AnimationUtils.loadAnimation(this, R.anim.fadein)); 552 setContentView(view); 553 ConstraintLayout constraintLayout = findViewById(R.id.swipe_result); 554 ConstraintLayout constraintLayout1 = findViewById(R.id.title_bar); 555 ConstraintLayout constraintLayout2 = findViewById(R.id.layout_result); 556 constraintLayout.setBackgroundColor(back_color); 557 constraintLayout1.setBackgroundColor(back_color); 558 constraintLayout2.setBackgroundColor(back_color); 559 } 560 561 if (this.chats.isEmpty() || this.chats.length() < 1000) { 562 this.chats = ""; 563 BufferedReader reader = null; 564 try { 565 reader = new BufferedReader( 566 new InputStreamReader(getAssets().open("sample.txt"))); 567 String mLine; 568 while ((mLine = reader.readLine()) != null) { 569 this.chats = this.chats + '\n' + mLine; 570 } 571 } catch (IOException e) { 572 } finally { 573 if (reader != null) { 574 try { 575 reader.close(); 576 } catch (IOException e) { 577 } 578 } 579 } 580 } 581 final com.asimplesock.chatistics.Names names = getNames(this.chats); 582 if (names.isGroup == true) { 583 return true; 584 } 585 Scanner sn = new Scanner(this.chats); 586 StringBuilder ch = new StringBuilder(); 587 sn.nextLine(); 588 String de = sn.nextLine(); 589 if (de.length() > 67) { 590 sn.nextLine(); 591 } else { 592 ch.append(de); 593 } 594 while (sn.hasNextLine()) 595 ch.append(sn.nextLine()).append("\n"); 596 this.chats = ch.toString(); 597 this.firstMsg = this.chats.substring(0, this.chats.indexOf(',')); 598 599 this.name1 = names.getName1(); 600 this.name2 = names.getName2(); 601 this.mTexts1 = names.getTexts1(); 602 this.mTexts2 = names.getTexts2(); 603 this.mWords1 = names.getWords1(); 604 this.mWords2 = names.getWords2(); 605 MoreAsyncTask moreAsyncTask = new MoreAsyncTask(); 606 moreAsyncTask.execute(); 607 MostCommonASyncTask mostCommonASyncTask = new MostCommonASyncTask(); 608 mostCommonASyncTask.execute(); 609 AnotherASyncTask anotherASyncTask = new AnotherASyncTask(); 610 anotherASyncTask.execute(); 611 double[] i = getRatio(); 612 String a1 = i[0] + ""; 613 String a2 = i[1] + ""; 614 if (!backMode && !(rName1.equals("Sample") || rName1.equals("Data"))) { 615 a1 = a1.equals("1.0") ? "1" : a1.substring(0, 4); 616 a2 = a2.equals("1.0") ? "1" : a2.substring(0, 4); 617 } else { 618 if (a1.length() > 5) { 619 a1 = a1.substring(0, 4); 620 } 621 if (a2.length() > 5) { 622 a2 = a2.substring(0, 4); 623 } 624 } 625 List<SliceValue> pieData1 = new ArrayList<>(); 626 List<SliceValue> pieData2 = new ArrayList<>(); 627 pieData1.add(new SliceValue(this.mTexts1, color_one)); 628 pieData1.add(new SliceValue(this.mTexts2, color_two)); 629 pieData2.add(new SliceValue(this.mWords1, color_one)); 630 pieData2.add(new SliceValue(this.mWords2, color_two)); 631 PieChartData pieChartData1 = new PieChartData(pieData1); 632 PieChartData pieChartData2 = new PieChartData(pieData2); 633 TextView textView2 = findViewById(R.id.textView2); 634 TextView textView3 = findViewById(R.id.textView3); 635 TextView textView4 = findViewById(R.id.textView4); 636 TextView textView6 = findViewById(R.id.textView6); 637 TextView textView17 = findViewById(R.id.textView17); 638 TextView textView18 = findViewById(R.id.textView18); 639 TextView textView20 = findViewById(R.id.textView20); 640 TextView textView9 = findViewById(R.id.textView9); 641 TextView textView10 = findViewById(R.id.textView10); 642 TextView textView13 = findViewById(R.id.textView13); 643 TextView textView22 = findViewById(R.id.textView22); 644 TextView textView19 = findViewById(R.id.textView19); 645 TextView textView14 = findViewById(R.id.textView14); 646 TextView textView21 = findViewById(R.id.textView21); 647 TextView textView16 = findViewById(R.id.textView16); 648 TextView textView15 = findViewById(R.id.textView15); 649 TextView textView26 = findViewById(R.id.textView26); 650 TextView textView25 = findViewById(R.id.textView25); 651 PieChartView pieChartView1 = findViewById(R.id.chart1); 652 PieChartView pieChartView2 = findViewById(R.id.chart2); 653 pieChartView1.setPieChartData(pieChartData1); 654 pieChartView2.setPieChartData(pieChartData2); 655 textView2.setTypeface(getResources().getFont(R.font.chinkala)); 656 textView3.setTypeface(getResources().getFont(R.font.chinkala)); 657 textView4.setTypeface(getResources().getFont(R.font.chinkala)); 658 textView9.setTypeface(getResources().getFont(R.font.chinkala)); 659 textView10.setTypeface(getResources().getFont(R.font.chinkala)); 660 textView13.setTypeface(getResources().getFont(R.font.chinkala)); 661 textView19.setTypeface(getResources().getFont(R.font.chinkala)); 662 textView22.setTypeface(getResources().getFont(R.font.chinkala)); 663 textView6.setTypeface(getResources().getFont(R.font.chinkala)); 664 textView14.setTypeface(getResources().getFont(R.font.chinkala)); 665 textView17.setTypeface(getResources().getFont(R.font.chinkala)); 666 textView18.setTypeface(getResources().getFont(R.font.chinkala)); 667 textView21.setTypeface(getResources().getFont(R.font.chinkala)); 668 textView20.setTypeface(getResources().getFont(R.font.chinkala)); 669 textView16.setTypeface(getResources().getFont(R.font.chinkala)); 670 textView16.setTypeface(getResources().getFont(R.font.chinkala)); 671 textView15.setTypeface(getResources().getFont(R.font.chinkala)); 672 textView26.setTypeface(getResources().getFont(R.font.chinkala)); 673 textView25.setTypeface(getResources().getFont(R.font.chinkala)); 674 if (this.name1.length() + this.name2.length() > 14 && this.name1.length() + this.name2.length() < 20) { 675 textView2.setTextSize(36.0F); 676 textView3.setTextSize(36.0F); 677 } else if (this.name1.length() + this.name2.length() > 20) { 678 textView2.setTextSize(32.0F); 679 textView3.setTextSize(32.0F); 680 textView15.setTextSize(24.0F); 681 textView16.setTextSize(24.0F); 682 } 683 textView2.setTextColor(color_one); 684 textView3.setTextColor(color_two); 685 textView15.setTextColor(color_one); 686 textView16.setTextColor(color_two); 687 textView17.setTextColor(color_one); 688 textView18.setTextColor(color_two); 689 textView20.setTextColor(color_one); 690 textView21.setTextColor(color_two); 691 textView2.setText(this.name1); 692 textView3.setText(this.name2); 693 textView4.setText(getFirstMsg()); 694 textView14.setText(((this.mTexts1 + this.mTexts2) + "")); 695 textView15.setText(this.name1); 696 textView16.setText(this.name2); 697 textView17.setText(("" + this.mTexts1)); 698 textView18.setText(("" + this.mTexts2)); 699 textView20.setText((a1 + " ")); 700 textView21.setText((" " + a2)); 701 textView6.setText((this.DaysBetween + "")); 702 if (!single) { 703 ConstraintLayout constraintLayout = findViewById(R.id.swipe_result); 704 constraintLayout.setOnTouchListener(new OnSwipeTouchListener(MainActivity.this) { 705 public void onSwipeTop() { 706 } 707 708 public void onSwipeRight() { 709 setContentView(R.layout.splash_screen); 710 } 711 712 public void onSwipeLeft() { 713 moreInfo(null); 714 } 715 716 public void onSwipeBottom() { 717 } 718 }); 719 } 720 viewNum = 1; 721 return false; 722 } 723 724 private Names getNames(String s) { 725 int pers = 1; 726 Names names = new Names(); 727 int texts1 = 0; 728 int texts2 = 0; 729 int words1 = 0; 730 int words2 = 0; 731 Scanner sn = new Scanner(s); 732 String temp = " "; 733 String s1 = " "; 734 String possibleNames[] = new String[500]; 735 int possibleNamesCount[] = new int[500]; 736 int passedFiveCounts = 0; 737 boolean isNewName = true; 738 int possibleNamesFound = 0; 739 /** New Fortified Name Finder **/ 740 //This is here to stay to aid in group detection 741 while (sn.hasNext()) { 742 try { 743 s1 = sn.nextLine(); 744 if (s1.indexOf("-") > 0) s1 = s1.substring(s1.indexOf("-")); 745 if (s1.indexOf(":") != -1 && s1.indexOf("-") != -1 && (s1.indexOf(":") - s1.indexOf("-") > 2)) { 746 temp = s1.substring(s1.indexOf("-") + 2, s1.indexOf(":")); 747 isNewName = true; 748 for (int i = 0; i <= possibleNamesFound; i++) { 749 if (possibleNames[0] == null) { 750 possibleNames[0] = temp; 751 possibleNamesFound = 1; 752 } 753 if (possibleNames[i] == null) break; 754 if (possibleNames[i].equals(temp)) { 755 if (possibleNamesCount[i] == 6) { 756 passedFiveCounts++; 757 } 758 possibleNamesCount[i]++; 759 isNewName = false; 760 break; 761 } else if (possibleNames[i] == null) { 762 possibleNames[i] = temp; 763 possibleNamesFound++; 764 } 765 } 766 if (isNewName) { 767 possibleNames[possibleNamesFound++] = temp; 768 } 769 } 770 } catch (Exception e) { 771 e.printStackTrace(); 772 } 773 } 774 boolean first = true; 775 people = possibleNames; 776 peopleFreq = possibleNamesCount; 777 members = possibleNamesFound; 778 int tempo = 0; 779 int n = members; 780 for (int i = 0; i < n - 1; i++) 781 for (int j = 0; j < n - i - 1; j++) 782 if (peopleFreq[j] < peopleFreq[j + 1]) { 783 tempo = peopleFreq[j]; 784 peopleFreq[j] = peopleFreq[j + 1]; 785 peopleFreq[j + 1] = tempo; 786 temp = people[j]; 787 people[j] = people[j + 1]; 788 people[j + 1] = temp; 789 } 790 name1 = possibleNames[0]; 791 name2 = possibleNames[1]; 792 if (possibleNamesCount[2] > 50) { 793 names.isGroup = true; 794 } 795 StringTokenizer stringTokenizer = new StringTokenizer(name1); 796 StringTokenizer stringTokenizer1 = new StringTokenizer(name2); 797 this.rName1 = name1; 798 this.rName2 = name2; 799 names.setName1(stringTokenizer.nextToken() + " "); 800 names.setName2(" " + stringTokenizer1.nextToken()); 801 sn.close(); 802 Scanner sc = new Scanner(s); 803 while (sc.hasNext()) { 804 StringTokenizer stringTokenizer2; 805 temp = sc.nextLine(); 806 if (temp.contains(name1 + ":")) { 807 texts1++; 808 pers = 1; 809 stringTokenizer2 = new StringTokenizer(temp.substring(temp.lastIndexOf(":"))); 810 } else if (temp.contains(name2 + ":")) { 811 texts2++; 812 pers = -1; 813 stringTokenizer2 = new StringTokenizer(temp.substring(temp.lastIndexOf((":")))); 814 } else { 815 stringTokenizer2 = new StringTokenizer(temp); 816 } 817 if (stringTokenizer2.hasMoreTokens()) stringTokenizer2.nextToken(); 818 while (stringTokenizer2.hasMoreTokens()) { 819 stringTokenizer2.nextToken(); 820 if (pers == 1) { 821 words1++; 822 continue; 823 } 824 words2++; 825 } 826 } 827 names.setWords1(words1); 828 names.setWords2(words2); 829 names.setTexts1(texts1); 830 names.setTexts2(texts2); 831 return names; 832 } 833 834 835 public long getTotalDays() { 836 Date date1, date2; 837 String dateBeforeString = ""; 838 String dateAfterString = ""; 839 try { 840 dateBeforeString = getProperDate(this.firstMsg); 841 if (dateBeforeString == null) { 842 return 0L; 843 } 844 } catch (Exception e) { 845 // Toast.makeText(getApplicationContext(), "First Date Parse Error, try deleting the first few messages.", Toast.LENGTH_LONG).show(); 846 } 847 try { 848 dateAfterString = getProperDate(this.lastMsg); 849 } catch (Exception e) { 850 // Toast.makeText(getApplicationContext(), "Late Date Parse Error, try deleting the last few messages.", Toast.LENGTH_LONG).show(); 851 } 852 SimpleDateFormat myFormat = new SimpleDateFormat("dd MM yyyy"); 853 try { 854 date2 = myFormat.parse(dateAfterString.substring(0, 2) + " " + dateAfterString.substring(3, 5) + " 20" + dateAfterString.substring(8, 10)); 855 date1 = myFormat.parse(dateBeforeString.substring(0, 2) + " " + dateBeforeString.substring(3, 5) + " 20" + dateBeforeString.substring(8, 10)); 856 } catch (Exception e) { 857 e.printStackTrace(); 858 return 1L; 859 } 860 assert date2 != null; 861 assert date1 != null; 862 long diff = date2.getTime() - date1.getTime(); 863 long daysBetween = diff / 86400000L; 864 if (daysBetween == 0L) 865 return 1L; 866 return daysBetween + 1; 867 } 868 869 public String getFirstMsg() { 870 SimpleDateFormat myFormat = new SimpleDateFormat("dd MM yyyy"); 871 Date date = null; 872 try { 873 date = myFormat.parse("01 01 1970"); 874 String dateAfterString = getProperDate(this.firstMsg); 875 date = myFormat.parse(dateAfterString.substring(0, 2) + " " + dateAfterString.substring(3, 5) + " 20" + dateAfterString.substring(8, 10)); 876 } catch (Exception e) { 877 e.printStackTrace(); 878 dateError = true; 879 // Toast.makeText(getApplicationContext(), e.getMessage() + "Failed to calculate the date, sorry.", Toast.LENGTH_LONG).show(); 880 } 881 myFormat = new SimpleDateFormat("dd MMMM YYYY"); 882 assert date != null; 883 return myFormat.format(date); 884 } 885 886 @RequiresApi(api = 26) 887 public void moreInfo(View v) { 888 if (!single) { 889 setContentView(R.layout.activity_more); 890 ConstraintLayout constraintLayout = findViewById(R.id.swipe_result); 891 ConstraintLayout constraintLayout1 = findViewById(R.id.layout_more); 892 constraintLayout.setBackgroundColor(back_color); 893 constraintLayout1.setBackgroundColor(back_color); 894 } 895 TextView textView5 = findViewById(R.id.textView5); 896 TextView textView7 = findViewById(R.id.textView7); 897 TextView textView8 = findViewById(R.id.textView8); 898 TextView textView12 = findViewById(R.id.textView12); 899 TextView textView24 = findViewById(R.id.textView24); 900 TextView textView29 = findViewById(R.id.textView29); 901 TextView textView32 = findViewById(R.id.textView32); 902 TextView textView33 = findViewById(R.id.textView33); 903 TextView textView36 = findViewById(R.id.textView36); 904 TextView textView37 = findViewById(R.id.textView37); 905 TextView textView39 = findViewById(R.id.textView39); 906 TextView textView40 = findViewById(R.id.textView40); 907 TextView textView42 = findViewById(R.id.textView42); 908 TextView textView43 = findViewById(R.id.textView43); 909 TextView textView = findViewById(R.id.textView); 910 TextView textView11 = findViewById(R.id.textView11); 911 TextView textView30 = findViewById(R.id.textView30); 912 TextView textView34 = findViewById(R.id.textView34); 913 TextView textView38 = findViewById(R.id.textView38); 914 TextView textView41 = findViewById(R.id.textView41); 915 TextView textView35 = findViewById(R.id.textView35); 916 TextView textView44 = findViewById(R.id.textView44); 917 TextView textViewTimeH = findViewById(R.id.textViewTimeH); 918 TextView textViewTime = findViewById(R.id.textViewTime); 919 if (!single) { 920 TextView textView23 = findViewById(R.id.textView23); 921 TextView textView83 = findViewById(R.id.textView83); 922 TextView plus = findViewById(R.id.plus); 923 try { 924 textView23.setTypeface(getResources().getFont(R.font.chinkala)); 925 textView83.setTypeface(getResources().getFont(R.font.chinkala)); 926 } catch (Exception e) { 927 } 928 plus.setTypeface(getResources().getFont(R.font.chinkala)); 929 if (this.name1.length() + this.name2.length() > 14 && this.name1.length() + this.name2.length() < 20) { 930 textView23.setTextSize(36.0F); 931 textView83.setTextSize(36.0F); 932 } else if (this.name1.length() + this.name2.length() > 20) { 933 textView23.setTextSize(32.0F); 934 textView83.setTextSize(32.0F); 935 } 936 textView23.setTextColor(color_one); 937 textView83.setTextColor(color_two); 938 textView23.setText(this.name1); 939 textView83.setText(this.name2); 940 } 941 try { 942 textViewTimeH.setTypeface(getResources().getFont(R.font.chinkala)); 943 textViewTime.setTypeface(getResources().getFont(R.font.chinkala)); 944 textView.setTypeface(getResources().getFont(R.font.chinkala)); 945 textView5.setTypeface(getResources().getFont(R.font.chinkala)); 946 textView7.setTypeface(getResources().getFont(R.font.chinkala)); 947 textView8.setTypeface(getResources().getFont(R.font.chinkala)); 948 textView11.setTypeface(getResources().getFont(R.font.chinkala)); 949 textView12.setTypeface(getResources().getFont(R.font.chinkala)); 950 textView24.setTypeface(getResources().getFont(R.font.chinkala)); 951 textView29.setTypeface(getResources().getFont(R.font.chinkala)); 952 textView30.setTypeface(getResources().getFont(R.font.chinkala)); 953 textView34.setTypeface(getResources().getFont(R.font.chinkala)); 954 textView38.setTypeface(getResources().getFont(R.font.chinkala)); 955 textView39.setTypeface(getResources().getFont(R.font.chinkala)); 956 textView40.setTypeface(getResources().getFont(R.font.chinkala)); 957 textView41.setTypeface(getResources().getFont(R.font.chinkala)); 958 textView42.setTypeface(getResources().getFont(R.font.chinkala)); 959 textView43.setTypeface(getResources().getFont(R.font.chinkala)); 960 textView35.setTypeface(getResources().getFont(R.font.chinkala)); 961 textView44.setTypeface(getResources().getFont(R.font.chinkala)); 962 } catch (Exception e) { 963 } 964 965 LinearLayout linearLayout3 = findViewById(R.id.linearLayout3); 966 if (!this.processed) 967 linearLayout3.setVisibility(View.GONE); 968 969 LinearLayout.LayoutParams params1 = (LinearLayout.LayoutParams) textView32.getLayoutParams(); 970 params1.weight = this.moreData.getPer1(); 971 textView32.setLayoutParams(params1); 972 LinearLayout.LayoutParams params2 = (LinearLayout.LayoutParams) textView33.getLayoutParams(); 973 params2.weight = this.moreData.getPer2(); 974 textView33.setLayoutParams(params2); 975 LinearLayout.LayoutParams params3 = (LinearLayout.LayoutParams) textView36.getLayoutParams(); 976 params3.weight = this.moreData.getTime1(); 977 textView36.setLayoutParams(params3); 978 LinearLayout.LayoutParams params4 = (LinearLayout.LayoutParams) textView37.getLayoutParams(); 979 params4.weight = this.moreData.getTime2(); 980 textView37.setLayoutParams(params4); 981 if (this.DaysBetween == 0L) { 982 // Toast.makeText(getApplicationContext(), "Couldn't calculate days between", Toast.LENGTH_LONG).show(); 983 return; 984 } 985 986 textView7.setTextColor(color_one); 987 textView8.setTextColor(color_two); 988 textView24.setTextColor(color_one); 989 textView29.setTextColor(color_two); 990 textView32.setBackgroundColor(color_one); 991 textView33.setBackgroundColor(color_two); 992 textView36.setBackgroundColor(color_one); 993 textView37.setBackgroundColor(color_two); 994 textView39.setTextColor(color_one); 995 textView40.setTextColor(color_two); 996 textView42.setTextColor(color_one); 997 textView43.setTextColor(color_two); 998 textView35.setTextColor(color_one); 999 textView44.setTextColor(color_two); 1000 1001 textView35.setText((this.moreData.getTime1() + "")); 1002 textView44.setText((this.moreData.getTime2() + "")); 1003 1004 textView39.setText((this.moreData.getMedia1() + "")); 1005 textView40.setText((this.moreData.getMedia2() + "")); 1006 textView42.setText((this.moreData.getDel1() + "")); 1007 textView43.setText((this.moreData.getDel2() + "")); 1008 textView5.setText(((this.moreData.getAvgTexts1() + this.moreData.getAvgTexts2()) + " ").substring(0, 4)); 1009 textView7.setText((this.moreData.getAvgTexts1() + " ").substring(0, 4)); 1010 textView8.setText((this.moreData.getAvgTexts2() + " ").substring(0, 4)); 1011 textView12.setText((((this.moreData.getAvgWords1() + this.moreData.getAvgWords2()) / 2.0D) + " ").substring(0, 4)); 1012 textView24.setText((this.moreData.getAvgWords1() + " ").substring(0, 4)); 1013 textView29.setText((this.moreData.getAvgWords2() + " ").substring(0, 4)); 1014 viewNum = 2; 1015 } 1016 1017 public String getProperDate(String s) { 1018 String ds, ms, ys; 1019 boolean format = false; 1020 StringTokenizer stringTokenizer = new StringTokenizer(s, "/."); 1021 if (!stringTokenizer.hasMoreTokens()) 1022 return null; 1023 int d = Integer.parseInt(stringTokenizer.nextToken()); 1024 if (d < 10) { 1025 ds = "0" + d; 1026 } else { 1027 if (d > 12) { 1028 neverFormat = true; 1029 } 1030 ds = "" + d; 1031 } 1032 if (!stringTokenizer.hasMoreTokens()) 1033 return null; 1034 int m = Integer.parseInt(stringTokenizer.nextToken()); 1035 if (m < 10) { 1036 ms = "0" + m; 1037 } else if (m > 12) { 1038 ms = "" + m; 1039 format = true; 1040 hameshaFormat = true; 1041 if (neverFormat) hameshaFormat = false; 1042 } else { 1043 ms = "" + m; 1044 } 1045 if (!stringTokenizer.hasMoreTokens()) 1046 return null; 1047 String yy = stringTokenizer.nextToken(); 1048 if (yy.length() == 4) { 1049 ys = yy; 1050 } else { 1051 ys = "20" + yy; 1052 } 1053 if (format || hameshaFormat) { 1054 s = ms + " " + ds + " " + ys; 1055 } else { 1056 s = ds + " " + ms + " " + ys; 1057 } 1058 return s; 1059 } 1060 1061 public void findPerTimesTextedFirst(MoreData moreData) { 1062 int per1 = 1; 1063 int per2 = 0; 1064 int media1 = 0; 1065 int media2 = 0; 1066 int deleted1 = 0; 1067 int deleted2 = 0; 1068 String date = "01/01/1970"; 1069 boolean firstDateFound = false; 1070 String betterDate = date; 1071 int foundEmojiCount1 = 0; 1072 int foundEmojiCount2 = 0; 1073 1074 1075 String lastTime = "00:00"; 1076 String temporary = ""; 1077 String messageTime = ""; 1078 1079 Pattern pattern = "ADD EMOJI REGEX HERE" 1080 Scanner sn = new Scanner(this.chats); 1081 while (sn.hasNextLine()) { 1082 try { 1083 String temp = sn.nextLine(); 1084 try { 1085 if (temp.indexOf(',') != -1 && temp.indexOf("-") != -1 && temp.indexOf('-') - temp.indexOf(',') > 3) { 1086 temporary = temp.substring(temp.indexOf(',') + 2, temp.indexOf('-') - 1) + " "; 1087 messageTime = temporary.substring(0, temporary.indexOf(" ")); 1088 int diff = timeDiff(lastTime, messageTime); 1089 if (diff <= 5 && diff != 0) { 1090 minutesSpent += diff; 1091 } 1092 lastTime = messageTime; 1093 int o = minutesSpent; 1094 } 1095 } catch (Exception e) { 1096 e.printStackTrace(); 1097 } 1098 if (temp.contains(this.rName1 + ":") && temp.indexOf(',') != -1) { 1099 if (!date.equals(temp.substring(0, temp.indexOf(',')))) { 1100 per1++; 1101 if (temp.indexOf(',') != -1) { 1102 date = temp.substring(0, temp.indexOf(',')); 1103 if (!firstDateFound) { 1104 betterDate = date; 1105 firstDateFound = true; 1106 } 1107 getProperDate(date); 1108 } 1109 } 1110 if (temp.contains("<Media omitted>")) { 1111 media1++; 1112 } else if (temp.contains("You deleted this message") || temp.contains("This message was deleted")) { 1113 deleted1++; 1114 } 1115 Matcher matcher = pattern.matcher(temp.substring(temp.lastIndexOf(':'))); 1116 while (matcher.find()) { 1117 this.mEmojiCount1[this.lent1++] = matcher.group(0); 1118 foundEmojiCount1++; 1119 } 1120 continue; 1121 } 1122 if (temp.contains(this.rName2 + ":") && temp.indexOf(',') != -1) { 1123 if (!date.equals(temp.substring(0, temp.indexOf(',')))) { 1124 per2++; 1125 if (temp.indexOf(',') != -1) { 1126 date = temp.substring(0, temp.indexOf(',')); 1127 getProperDate(date); 1128 if (!firstDateFound) { 1129 betterDate = date; 1130 firstDateFound = true; 1131 } 1132 getProperDate(date); 1133 } 1134 } 1135 if (temp.contains("<Media omitted>")) { 1136 media2++; 1137 } else if (temp.contains("You deleted this message") || temp.contains("This message was deleted")) { 1138 deleted2++; 1139 } 1140 Matcher matcher = pattern.matcher(temp.substring(temp.lastIndexOf(":"))); 1141 while (matcher.find()) { 1142 this.mEmojiCount2[this.lent2++] = matcher.group(0); 1143 foundEmojiCount2++; 1144 } 1145 } 1146 } catch (Exception e) { 1147 e.printStackTrace(); 1148 } 1149 } 1150 moreData.setMedia1(media1); 1151 moreData.setMedia2(media2); 1152 moreData.setDel1(deleted1); 1153 moreData.setDel2(deleted2); 1154 int mPer1 = per1 * 100 / (per1 + per2); 1155 int mPer2 = per2 * 100 / (per1 + per2); 1156 if (mPer1 + mPer2 < 100) 1157 if (mPer1 > mPer2) { 1158 mPer1++; 1159 } else { 1160 mPer2++; 1161 } 1162 moreData.setPer1(mPer1); 1163 moreData.setPer2(mPer2); 1164 moreData.setTime1(foundEmojiCount1); 1165 moreData.setTime2(foundEmojiCount2); 1166 this.lastMsg = date; 1167 this.firstMsg = betterDate; 1168 System.out.println("hi"); 1169 } 1170 1171 public void dirtyMethod() { 1172 String s = this.chats; 1173 Scanner sn = new Scanner(s); 1174 boolean found = false; 1175 int i = 20000; 1176 int[] count1 = new int[i]; 1177 int[] count2 = new int[i]; 1178 for (int k = 0; k < i; k++) { 1179 count1[k] = 1; 1180 count2[k] = 1; 1181 } 1182 String[] string1 = new String[i]; 1183 String[] string2 = new String[i]; 1184 string1[0] = "Hi"; 1185 string2[0] = "Hi"; 1186 int len1 = 0; 1187 int len2 = 0; 1188 while (sn.hasNextLine()) { 1189 String temp = sn.nextLine(); 1190 if (temp.indexOf(':') != -1) { 1191 if (temp.contains(this.rName1 + ":")) { 1192 temp = temp.substring(temp.lastIndexOf(':') + 1); 1193 StringTokenizer stringTokenizer = new StringTokenizer(temp); 1194 label140: 1195 while (stringTokenizer.hasMoreTokens()) { 1196 String word = stringTokenizer.nextToken(); 1197 for (int j = 0; j < len1; j++) { 1198 found = false; 1199 if (word.equalsIgnoreCase(string1[j])) { 1200 count1[j] = count1[j] + 1; 1201 found = true; 1202 continue label140; 1203 } 1204 } 1205 if (!found && 1206 len1 < i - 1) 1207 string1[++len1] = word; 1208 } 1209 continue; 1210 } 1211 if (temp.contains(this.rName2 + ":")) { 1212 temp = temp.substring(temp.lastIndexOf(':') + 1); 1213 StringTokenizer stringTokenizer = new StringTokenizer(temp); 1214 label141: 1215 while (stringTokenizer.hasMoreTokens()) { 1216 String word = stringTokenizer.nextToken(); 1217 for (int j = 0; j < len2; j++) { 1218 found = false; 1219 if (word.equalsIgnoreCase(string2[j])) { 1220 count2[j] = count2[j] + 1; 1221 found = true; 1222 continue label141; 1223 } 1224 } 1225 if (!found && 1226 len2 < i - 1) 1227 string2[++len2] = word; 1228 } 1229 } 1230 } 1231 } 1232 for (i = 0; i < len1 - 1; i++) { 1233 for (int j = 0; j < len1 - i - 1; j++) { 1234 if (count1[j] < count1[j + 1]) { 1235 int ii = count1[j]; 1236 count1[j] = count1[j + 1]; 1237 count1[j + 1] = ii; 1238 String iii = string1[j]; 1239 string1[j] = string1[j + 1]; 1240 string1[j + 1] = iii; 1241 } 1242 } 1243 } 1244 for (i = 0; i < len2 - 1; i++) { 1245 for (int j = 0; j < len2 - i - 1; j++) { 1246 if (count2[j] < count2[j + 1]) { 1247 int ii = count2[j]; 1248 count2[j] = count2[j + 1]; 1249 count2[j + 1] = ii; 1250 String iii = string2[j]; 1251 string2[j] = string2[j + 1]; 1252 string2[j + 1] = iii; 1253 } 1254 } 1255 } 1256 for (i = 0; i < 100; i++) { 1257 this.words1[i] = string1[i]; 1258 this.fWords1[i] = count1[i]; 1259 this.words2[i] = string2[i]; 1260 this.fWords2[i] = count2[i]; 1261 } 1262 this.fEmoji1 = new int[this.mEmojiCount1.length]; 1263 this.fEmoji2 = new int[this.mEmojiCount2.length]; 1264 int l; 1265 for (l = 0; l < this.lent1; l++) { 1266 for (int m = l + 1; m < this.lent1; m++) { 1267 if (this.mEmojiCount1[l].equals(this.mEmojiCount1[m])) { 1268 boolean before = false; 1269 for (int n = 0; n < l; n++) { 1270 if (this.mEmojiCount1[l].equals(this.mEmojiCount1[n])) { 1271 before = true; 1272 break; 1273 } 1274 } 1275 if (!before) 1276 this.fEmoji1[l] = this.fEmoji1[l] + 1; 1277 } 1278 } 1279 } 1280 for (l = 0; l < this.lent2; l++) { 1281 for (int m = l + 1; m < this.lent2; m++) { 1282 if (this.mEmojiCount2[l].equals(this.mEmojiCount2[m])) { 1283 boolean before = false; 1284 for (int n = 0; n < l; n++) { 1285 if (this.mEmojiCount2[l].equals(this.mEmojiCount2[n])) { 1286 before = true; 1287 break; 1288 } 1289 } 1290 if (!before) 1291 this.fEmoji2[l] = this.fEmoji2[l] + 1; 1292 } 1293 } 1294 } 1295 for (i = 0; i < len1 - 1; i++) { 1296 for (int j = 0; j < len1 - i - 1; j++) { 1297 if (this.fEmoji1[j] < this.fEmoji1[j + 1]) { 1298 int ii = this.fEmoji1[j]; 1299 this.fEmoji1[j] = this.fEmoji1[j + 1]; 1300 this.fEmoji1[j + 1] = ii; 1301 String iii = this.mEmojiCount1[j]; 1302 this.mEmojiCount1[j] = this.mEmojiCount1[j + 1]; 1303 this.mEmojiCount1[j + 1] = iii; 1304 } 1305 } 1306 } 1307 for (i = 0; i < len2 - 1; i++) { 1308 for (int j = 0; j < len2 - i - 1; j++) { 1309 if (this.fEmoji2[j] < this.fEmoji2[j + 1]) { 1310 int ii = this.fEmoji2[j]; 1311 this.fEmoji2[j] = this.fEmoji2[j + 1]; 1312 this.fEmoji2[j + 1] = ii; 1313 String iii = this.mEmojiCount2[j]; 1314 this.mEmojiCount2[j] = this.mEmojiCount2[j + 1]; 1315 this.mEmojiCount2[j + 1] = iii; 1316 } 1317 } 1318 } 1319 } 1320 1321 @SuppressLint("ClickableViewAccessibility") 1322 @RequiresApi(api = 26) 1323 public void meg(View view) { 1324 if (!single) { 1325 setContentView(R.layout.layout_emoji); 1326 ConstraintLayout constraintLayout = findViewById(R.id.swipe_result); 1327 ConstraintLayout constraintLayout1 = findViewById(R.id.layout_additional); 1328 constraintLayout.setBackgroundColor(back_color); 1329 constraintLayout1.setBackgroundColor(back_color); 1330 } 1331 TextView textView23 = findViewById(R.id.textView23); 1332 TextView textView83 = findViewById(R.id.textView83); 1333 textView23.setTypeface(getResources().getFont(R.font.chinkala)); 1334 textView83.setTypeface(getResources().getFont(R.font.chinkala)); 1335 textView23.setText(this.name1); 1336 textView83.setText(this.name2); 1337 textView23.setTextColor(color_one); 1338 textView83.setTextColor(color_two); 1339 TextView textView53 = findViewById(R.id.textView53); 1340 TextView textView54 = findViewById(R.id.textView54); 1341 TextView textView55 = findViewById(R.id.textView55); 1342 TextView textView56 = findViewById(R.id.textView56); 1343 TextView textView57 = findViewById(R.id.textView57); 1344 TextView textView58 = findViewById(R.id.textView58); 1345 TextView textView62 = findViewById(R.id.textView62); 1346 TextView textView63 = findViewById(R.id.textView63); 1347 TextView textView60 = findViewById(R.id.textView60); 1348 TextView textView61 = findViewById(R.id.textView61); 1349 TextView textView64 = findViewById(R.id.textView64); 1350 TextView textView65 = findViewById(R.id.textView65); 1351 TextView textView66 = findViewById(R.id.textView66); 1352 TextView textView67 = findViewById(R.id.textView67); 1353 TextView textView68 = findViewById(R.id.textView68); 1354 TextView textView69 = findViewById(R.id.textView69); 1355 TextView textView70 = findViewById(R.id.textView70); 1356 TextView textView71 = findViewById(R.id.textView71); 1357 TextView textView72 = findViewById(R.id.textView72); 1358 TextView textView73 = findViewById(R.id.textView73); 1359 TextView textView74 = findViewById(R.id.textView74); 1360 TextView textView75 = findViewById(R.id.textView75); 1361 TextView textView77 = findViewById(R.id.textView77); 1362 TextView textView76 = findViewById(R.id.textView76); 1363 TextView textView82 = findViewById(R.id.textView82); 1364 TextView textView84 = findViewById(R.id.textView84); 1365 TextView textView85 = findViewById(R.id.textView85); 1366 TextView textView86 = findViewById(R.id.textView86); 1367 TextView textView87 = findViewById(R.id.textView87); 1368 TextView textView88 = findViewById(R.id.textView88); 1369 TextView textView78 = findViewById(R.id.textView78); 1370 TextView textView79 = findViewById(R.id.textView79); 1371 TextView textView80 = findViewById(R.id.textView80); 1372 TextView textView81 = findViewById(R.id.textView81); 1373 TextView textView89 = findViewById(R.id.textView89); 1374 TextView textView90 = findViewById(R.id.textView90); 1375 TextView textView91 = findViewById(R.id.textView91); 1376 TextView textView92 = findViewById(R.id.textView92); 1377 TextView textView93 = findViewById(R.id.textView93); 1378 TextView textView94 = findViewById(R.id.textView94); 1379 if (this.name1.length() + this.name2.length() > 14 && this.name1.length() + this.name2.length() < 20) { 1380 textView23.setTextSize(36.0F); 1381 textView83.setTextSize(36.0F); 1382 } else if (this.name1.length() + this.name2.length() > 20) { 1383 textView23.setTextSize(32.0F); 1384 textView83.setTextSize(32.0F); 1385 } 1386 int i; 1387 for (i = 0; i < this.lent1; i++) { 1388 if (this.fEmoji1[i] > 0) 1389 this.ulen1++; 1390 } 1391 for (i = 0; i < this.lent2; i++) { 1392 if (this.fEmoji2[i] > 0) 1393 this.ulen2++; 1394 } 1395 if (this.ulen1 > 10) 1396 this.ulen1 = 10; 1397 switch (this.ulen1) { 1398 case 10: 1399 textView61.setText(this.mEmojiCount1[9]); 1400 textView88.setText((this.fEmoji1[9] + "")); 1401 case 9: 1402 textView60.setText(this.mEmojiCount1[8]); 1403 textView87.setText((this.fEmoji1[8] + "")); 1404 case 8: 1405 textView63.setText(this.mEmojiCount1[7]); 1406 textView86.setText((this.fEmoji1[7] + "")); 1407 case 7: 1408 textView62.setText(this.mEmojiCount1[6]); 1409 textView85.setText((this.fEmoji1[6] + "")); 1410 case 6: 1411 textView58.setText(this.mEmojiCount1[5]); 1412 textView84.setText((this.fEmoji1[5] + "")); 1413 case 5: 1414 textView57.setText(this.mEmojiCount1[4]); 1415 textView82.setText((this.fEmoji1[4] + "")); 1416 case 4: 1417 textView56.setText(this.mEmojiCount1[3]); 1418 textView76.setText((this.fEmoji1[3] + "")); 1419 case 3: 1420 textView55.setText(this.mEmojiCount1[2]); 1421 textView77.setText((this.fEmoji1[2] + "")); 1422 case 2: 1423 textView54.setText(this.mEmojiCount1[1]); 1424 textView75.setText((this.fEmoji1[1] + "")); 1425 case 1: 1426 textView53.setText(this.mEmojiCount1[0]); 1427 textView74.setText((this.fEmoji1[0] + "")); 1428 break; 1429 } 1430 if (this.ulen2 > 10) 1431 this.ulen2 = 10; 1432 switch (this.ulen2) { 1433 case 10: 1434 textView73.setText(this.mEmojiCount2[9]); 1435 textView94.setText((this.fEmoji2[9] + "")); 1436 case 9: 1437 textView72.setText(this.mEmojiCount2[8]); 1438 textView93.setText((this.fEmoji2[8] + "")); 1439 case 8: 1440 textView71.setText(this.mEmojiCount2[7]); 1441 textView92.setText((this.fEmoji2[7] + "")); 1442 case 7: 1443 textView70.setText(this.mEmojiCount2[6]); 1444 textView91.setText((this.fEmoji2[6] + "")); 1445 case 6: 1446 textView69.setText(this.mEmojiCount2[5]); 1447 textView90.setText((this.fEmoji2[5] + "")); 1448 case 5: 1449 textView68.setText(this.mEmojiCount2[4]); 1450 textView89.setText((this.fEmoji2[4] + "")); 1451 case 4: 1452 textView67.setText(this.mEmojiCount2[3]); 1453 textView81.setText((this.fEmoji2[3] + "")); 1454 case 3: 1455 textView66.setText(this.mEmojiCount2[2]); 1456 textView80.setText((this.fEmoji2[2] + "")); 1457 case 2: 1458 textView65.setText(this.mEmojiCount2[1]); 1459 textView79.setText((this.fEmoji2[1] + "")); 1460 case 1: 1461 textView64.setText(this.mEmojiCount2[0]); 1462 textView78.setText((this.fEmoji2[0] + "")); 1463 break; 1464 } 1465 if (!single) { 1466 ConstraintLayout constraintLayout = findViewById(R.id.swipe_result); 1467 constraintLayout.setOnTouchListener(new OnSwipeTouchListener(MainActivity.this) { 1468 public void onSwipeTop() { 1469 //Toast.makeText(MainActivity.this, "top", Toast.LENGTH_SHORT).show(); 1470 } 1471 1472 public void onSwipeRight() { 1473 additionalAct(null); 1474 } 1475 1476 public void onSwipeLeft() { 1477 finalAct(null); 1478 } 1479 1480 public void onSwipeBottom() { 1481 //Toast.makeText(MainActivity.this, "bottom", Toast.LENGTH_SHORT).show(); 1482 } 1483 }); 1484 } 1485 1486 viewNum = 4; 1487 } 1488 1489 public void finalAct(View view) { 1490 if (!single) { 1491 setContentView(R.layout.final_activity); 1492 RelativeLayout relativeLayout = findViewById(R.id.relativeLayout); 1493 relativeLayout.setBackgroundColor(back_color); 1494 } 1495 RelativeLayout relativeLayout = findViewById(R.id.relativeLayout); 1496 int k; 1497 for (k = 0; k < 1440; k += 160) { 1498 LinearLayout linearLayout1 = new LinearLayout(this); 1499 linearLayout1.setOrientation(LinearLayout.VERTICAL); 1500 RelativeLayout.LayoutParams params1 = new RelativeLayout.LayoutParams(-2, -2); 1501 params1.setMargins(k + 8, 0, 0, 0); 1502 linearLayout1.setLayoutParams(params1); 1503 int j = (int) (Math.random() * 24.0D); 1504 try { 1505 for (int i = 0; i < 50 && i < words1.length && this.words1[i] != null; i++, j = (int) (Math.random() * 24.0D)) { 1506 TextView textView = new TextView(this); 1507 if (!this.words1[i].equals("<Media") && !this.words1[i].equals("omitted>") && Character.isAlphabetic(this.words1[i].charAt(0))) { 1508 textView.setText(this.words1[i]); 1509 textView.setTextColor(color_one); 1510 textView.setTextSize((32 - j)); 1511 linearLayout1.addView(textView); 1512 } 1513 } 1514 relativeLayout.addView(linearLayout1); 1515 } catch (Exception e) { 1516 } 1517 } 1518 for (k = 80; k < 1440; k += 160) { 1519 LinearLayout linearLayout1 = new LinearLayout(this); 1520 linearLayout1.setOrientation(LinearLayout.VERTICAL); 1521 RelativeLayout.LayoutParams params1 = new RelativeLayout.LayoutParams(-2, -2); 1522 params1.setMargins(k + 8, 0, 0, 0); 1523 linearLayout1.setLayoutParams(params1); 1524 int j = (int) (Math.random() * 24.0D); 1525 try { 1526 for (int i = 0; i < 50 && i < words2.length && words2[i] != null; i++, j = (int) (Math.random() * 24.0D)) { 1527 TextView textView = new TextView(this); 1528 if (!this.words2[i].equals("<Media") && !this.words2[i].equals("omitted>") && Character.isAlphabetic(this.words2[i].charAt(0))) { 1529 textView.setText(this.words2[i]); 1530 textView.setTextColor(color_two); 1531 textView.setTextSize((32 - j)); 1532 linearLayout1.addView(textView); 1533 } 1534 } 1535 relativeLayout.addView(linearLayout1); 1536 } catch (Exception e) { 1537 } 1538 } 1539 viewNum = 5; 1540 } 1541 1542 public String getGroupName() { 1543 String gName = ""; 1544 Scanner sn = new Scanner(chats); 1545 String fir = sn.nextLine(); 1546 while (fir.indexOf('"') == fir.lastIndexOf('"')) { 1547 fir = sn.nextLine(); 1548 } 1549 String tfir = fir.substring(fir.indexOf('-') + 2); 1550 creator = tfir.substring(0, tfir.indexOf(' ')); 1551 gName = fir.substring(fir.indexOf('"') + 1, fir.lastIndexOf('"')); 1552 fir = sn.nextLine(); 1553 boolean done = false; 1554 while (!done) { 1555 try { 1556 firstDate = fir.substring(0, fir.indexOf(',')); 1557 firstDate = getProperDate(firstDate); 1558 done = true; 1559 } catch (Exception e) { 1560 fir = sn.nextLine(); 1561 done = false; 1562 } 1563 } 1564 SimpleDateFormat myFormat = new SimpleDateFormat("dd MM yyyy"); 1565 Date date = null; 1566 try { 1567 date = myFormat.parse(firstDate.substring(0, 2) + " " + firstDate.substring(3, 5) + " 20" + firstDate.substring(8, 10)); 1568 } catch (ParseException e) { 1569 e.printStackTrace(); 1570 } 1571 firstMsg = myFormat.format(date); 1572 myFormat = new SimpleDateFormat("dd MMMM YYYY"); 1573 firstDate = myFormat.format(date); 1574 sn.close(); 1575 return gName; 1576 } 1577 1578 1579 public void additionalAct(View vi) { 1580 BarChart chart = findViewById(R.id.ColumnChartView); 1581 LineChartView lineChartView = findViewById(R.id.LineChartView); 1582 if (!single) { 1583 setContentView(R.layout.activity_additonal); 1584 TextView textView23 = findViewById(R.id.textView23); 1585 TextView textView83 = findViewById(R.id.textView83); 1586 try { 1587 textView23.setTypeface(getResources().getFont(R.font.chinkala)); 1588 textView83.setTypeface(getResources().getFont(R.font.chinkala)); 1589 textView23.setText(this.name1); 1590 textView83.setText(this.name2); 1591 textView23.setTextColor(color_one); 1592 textView83.setTextColor(color_two); 1593 chart = findViewById(R.id.ColumnChartView); 1594 lineChartView = findViewById(R.id.LineChartView); 1595 chart.setBackgroundColor(back_color); 1596 lineChartView.setBackgroundColor(back_color); 1597 ConstraintLayout constraintLayout = findViewById(R.id.layout_additional); 1598 constraintLayout.setBackgroundColor(back_color); 1599 } catch (Exception e) { 1600 1601 } 1602 1603 try { 1604 if (this.name1.length() + this.name2.length() > 14 && this.name1.length() + this.name2.length() < 20) { 1605 textView23.setTextSize(36.0F); 1606 textView83.setTextSize(36.0F); 1607 } else if (this.name1.length() + this.name2.length() > 20) { 1608 textView23.setTextSize(32.0F); 1609 textView83.setTextSize(32.0F); 1610 } 1611 } catch (Exception e) { 1612 1613 } 1614 1615 } else { 1616 try { 1617 TextView textView6 = findViewById(R.id.textView6); 1618 textView6.setText("" + days_talked + "/" + getTotalDays()); 1619 TextView textView4 = findViewById(R.id.textView4); 1620 textView4.setText(getProperDate(getFirstMsg())); 1621 } catch (Exception e) { 1622 1623 } 1624 1625 } 1626 1627 try { 1628 TextView textView117 = findViewById(R.id.textView117); 1629 textView117.setText("" + streak); 1630 TextView textView118 = findViewById(R.id.textView118); 1631 if (current_Streak == streak) { 1632 textView118.setText("---"); 1633 } else { 1634 textView118.setText("" + streak_ended); 1635 } 1636 TextView textView116 = findViewById(R.id.textView116); 1637 TextView textView115 = findViewById(R.id.textView115); 1638 textView116.setTypeface(getResources().getFont(R.font.chinkala)); 1639 textView115.setTypeface(getResources().getFont(R.font.chinkala)); 1640 textView117.setTypeface(getResources().getFont(R.font.chinkala)); 1641 textView118.setTypeface(getResources().getFont(R.font.chinkala)); 1642 TextView textView119 = findViewById(R.id.textView119); 1643 TextView textView120 = findViewById(R.id.textView120); 1644 textView119.setTypeface(getResources().getFont(R.font.chinkala)); 1645 textView120.setTypeface(getResources().getFont(R.font.chinkala)); 1646 textView120.setText("" + current_Streak); 1647 } catch (Exception e) { 1648 1649 } 1650 1651 1652 YAxis leftAxis = chart.getAxisLeft(); 1653 leftAxis.setDrawGridLines(false); 1654 leftAxis.setLabelCount(8, false); 1655 leftAxis.setSpaceTop(15f); 1656 leftAxis.setDrawAxisLine(false); 1657 leftAxis.setTextColor(getColor(R.color.colorPrimary)); 1658 leftAxis.setAxisMinimum(0f); 1659 1660 YAxis rightAxis = chart.getAxisRight(); 1661 rightAxis.setDrawGridLines(false); 1662 rightAxis.setLabelCount(8, false); 1663 rightAxis.setSpaceTop(15f); 1664 rightAxis.setTextColor(getColor(R.color.colorPrimary)); 1665 rightAxis.setAxisMinimum(0f); 1666 rightAxis.setDrawAxisLine(false); 1667 data1.setValueTextSize(10f); 1668 chart.setData(data1); 1669 chart.setDrawGridBackground(false); 1670 chart.getDescription().setEnabled(false); 1671 chart.setScaleYEnabled(false); 1672 chart.getLegend().setEnabled(false); 1673 // chart.animateY(500); 1674 XAxis xAxis = chart.getXAxis(); 1675 xAxis.setDrawAxisLine(false); 1676 xAxis.setDrawGridLines(false); 1677 xAxis.setPosition(XAxis.XAxisPosition.BOTTOM); 1678 if (xAxisPos < 14) { 1679 xAxis.setLabelCount(xAxisPos, false); 1680 } else { 1681 xAxis.setLabelCount(12, false); 1682 } 1683 xAxis.setTextColor(getColor(R.color.white)); 1684 xAxis.setValueFormatter(new IndexAxisValueFormatter(xAxisLables)); 1685 final Viewport v = new Viewport(lineChartView.getMaximumViewport()); 1686 lineChartView.setMaximumViewport(v); 1687 lineChartView.setZoomType(ZoomType.HORIZONTAL); 1688 lineChartView.setLineChartData(data); 1689 viewNum = 3; 1690 1691 } 1692 1693 public void calculateChart() { 1694 int t = 1; 1695 List<PointValue> values = new ArrayList<PointValue>(); 1696 List<AxisValue> axisValues = new ArrayList<AxisValue>(); 1697 ArrayList<BarEntry> values1 = new ArrayList<>(); 1698 String date1 = ""; 1699 String date2 = ""; 1700 String date3 = ""; 1701 String temp = ""; 1702 int x = 0; 1703 int monthCount = 0; 1704 Date daterr = null; 1705 int countToday = 1; 1706 values.add(new PointValue(x++, 0)); 1707 String date = this.firstMsg; 1708 @SuppressLint("SimpleDateFormat") SimpleDateFormat myFormat = new SimpleDateFormat("dd MM yyyy"); 1709 try { 1710 dater = myFormat.parse("01 01 1970"); 1711 daterr = dater; 1712 myFormat = new SimpleDateFormat("MMM"); 1713 date2 = myFormat.format(dater); 1714 } catch (ParseException e) { 1715 1716 } 1717 Scanner sn = new Scanner(this.chats); 1718 while (sn.hasNextLine()) { 1719 temp = sn.nextLine(); 1720 if (temp.indexOf(',') == -1) { 1721 continue; 1722 } 1723 if (temp.contains(this.rName1 + ":") || temp.contains(this.rName2 + ":")) { 1724 if (date.equals(temp.substring(0, temp.indexOf(',')))) { 1725 countToday++; 1726 } else { 1727 if (temp.indexOf(',') != -1) { 1728 date = temp.substring(0, temp.indexOf(',')); 1729 } 1730 try { 1731 myFormat = new SimpleDateFormat("dd MM yyyy"); 1732 String dateAfterString = getProperDate(date); 1733 dater = myFormat.parse(dateAfterString.substring(0, 2) + " " + dateAfterString.substring(3, 5) + " 20" + dateAfterString.substring(8, 10)); 1734 t++; 1735 days_talked++; 1736 } catch (Exception e) { 1737 e.printStackTrace(); 1738 } 1739 myFormat = new SimpleDateFormat("MMM"); 1740 date3 = myFormat.format(dater); 1741 if (date2.equals(date3)) { 1742 monthCount += countToday; 1743 test++; 1744 } else { 1745 if (monthCount != 0) { 1746 xAxisLables.add(date2); 1747 float val = (float) monthCount; 1748 values1.add(new BarEntry(xAxisPos++, val)); 1749 monthCount = 0; 1750 } 1751 date2 = date3; 1752 } 1753 assert daterr != null; 1754 long diff = dater.getTime() - daterr.getTime(); 1755 long i = TimeUnit.DAYS.convert(diff, TimeUnit.MILLISECONDS); 1756 if (i <= 1) { 1757 1758 } else { 1759 if (t > streak) { 1760 streak = t; 1761 streak_ended = date; 1762 } 1763 t = 1; 1764 } 1765 while (i > 1 && i < 1000 && x > 1) { 1766 i--; 1767 values.add(new PointValue(x++, 0)); 1768 countToday = 1; 1769 1770 AxisValue axisValue = new AxisValue(x); 1771 axisValue.setLabel(date1); 1772 axisValues.add(axisValue); 1773 } 1774 values.add(new PointValue(x++, countToday)); 1775 countToday = 1; 1776 1777 AxisValue axisValue = new AxisValue(x); 1778 myFormat = new SimpleDateFormat("MMM"); 1779 date1 = myFormat.format(dater); 1780 axisValue.setLabel(date1); 1781 daterr = dater; 1782 axisValues.add(axisValue); 1783 } 1784 } 1785 1786 } 1787 xAxisLables.add(date2); 1788 float val = (float) monthCount; 1789 values1.add(new BarEntry(xAxisPos++, val)); 1790 1791 liner = new Line(values).setColor(color_one).setCubic(true); 1792 liner.setFilled(true); 1793 liner.setCubic(false); 1794 liner.setPointColor(color_two); 1795 liner.setHasPoints(false); 1796 1797 Axis axisY = new Axis().setHasLines(true); 1798 axisY.setName("Messages"); 1799 data.setAxisYLeft(axisY); 1800 1801 List<Line> lines = new ArrayList<Line>(); 1802 lines.add(liner); 1803 1804 data.setLines(lines); 1805 data.setAxisXBottom(new Axis(axisValues)); 1806 1807 BarDataSet set1; 1808 1809 set1 = new BarDataSet(values1, ""); 1810 set1.setColor(color_one); 1811 set1.setValueTextSize(10f); 1812 1813 ArrayList<IBarDataSet> dataSets = new ArrayList<>(); 1814 1815 dataSets.add(set1); 1816 1817 data1 = new BarData(dataSets); 1818 data1.setValueTextSize(10f); 1819 data1.setValueTextColor(getColor(R.color.white)); 1820 if (t > streak) { 1821 streak = t; 1822 } 1823 current_Streak = t; 1824 } 1825 1826 public void onBackPressed() { 1827 if (single && !singleSharing) { 1828 backToHome(null); 1829 return; 1830 } 1831 if (rName1 == null) { 1832 backToHome(null); 1833 return; 1834 } 1835 if ((rName1.equals("Sample") || rName1.equals("Data")) && singleSharing != true) { 1836 backToHome(null); 1837 return; 1838 } 1839 if (rName1.equals("Group")) { 1840 chats = ""; 1841 backToHome(null); 1842 return; 1843 } 1844 1845 if (isHowToShown) { 1846 isHowToShown = false; 1847 backToHome(null); 1848 return; 1849 } 1850 1851 switch (viewNum) { 1852 case 3: 1853 moreInfo(null); 1854 return; 1855 case 4: 1856 additionalAct(null); 1857 return; 1858 case 5: 1859 meg(null); 1860 return; 1861 } 1862 1863 lent1 = 0; 1864 1865 lent2 = 0; 1866 1867 shareAvailable = false; 1868 1869 xAxisPos = 0; 1870 1871 line = ""; 1872 1873 all = ""; 1874 1875 dater = null; 1876 1877 liner = null; 1878 1879 firstDate = ""; 1880 1881 creator = ""; 1882 1883 hameshaFormat = false; 1884 1885 anotherProcessed = false; 1886 1887 data = new LineChartData(); 1888 1889 name1 = "Name 1"; 1890 1891 name2 = "Name 2"; 1892 1893 mTexts1 = 0; 1894 1895 mTexts2 = 0; 1896 1897 mWords1 = 0; 1898 1899 mWords2 = 0; 1900 1901 ulen1 = 0; 1902 ulen2 = 0; 1903 1904 mEmojiCount1 = new String[100000]; 1905 mEmojiCount2 = new String[100000]; 1906 1907 firstMsg = "First Msg"; 1908 1909 lastMsg = "Last Msg"; 1910 1911 processed = true; 1912 1913 words1 = new String[100]; 1914 1915 fWords1 = new int[100]; 1916 1917 words2 = new String[100]; 1918 1919 fWords2 = new int[100]; 1920 1921 moreData = null; 1922 1923 DaysBetween = 0L; 1924 1925 people = new String[256]; 1926 1927 peopleFreq = new int[256]; 1928 1929 members = 0; 1930 1931 totalMsgs = 0; 1932 1933 int streak = 1; 1934 1935 int current_Streak = 1; 1936 1937 String streak_ended = ""; 1938 1939 int days_talked = 0; 1940 1941 backMode = true; 1942 1943 int minutesSpent = 0; 1944 1945 setContentView(R.layout.activity_result); 1946 ConstraintLayout constraintLayout = findViewById(R.id.loading); 1947 constraintLayout.setVisibility(View.VISIBLE); 1948 if (parse()) { 1949 Toast.makeText(this, "Can't do that while in Groupistics.", Toast.LENGTH_SHORT).show(); 1950 } 1951 } 1952 1953 public void share(View view) { 1954 viewNum = 1; 1955 singleSharing = true; 1956 onBackPressed(); 1957 shareAvailable = true; 1958 singleSharing = false; 1959 } 1960 1961 public void shareEasier(View view) { 1962 ConstraintLayout constraintLayout = findViewById(R.id.loading); 1963 constraintLayout.setVisibility(View.VISIBLE); 1964 if (cycleThroughViews()) 1965 shareImageUri(); 1966 viewNum = 1; 1967 onBackPressed(); 1968 } 1969 1970 private void shareImageUri() { 1971 Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE); 1972 1973 Bitmap result = Bitmap.createBitmap(bm0.getWidth(), bm0.getHeight() + bm1.getHeight(), Bitmap.Config.ARGB_8888); 1974 Canvas canvas = new Canvas(result); 1975 canvas.drawBitmap(bm0, 0, 0, null); 1976 canvas.drawBitmap(bm1, 0, bm0.getHeight(), null); 1977 1978 Bitmap graph = Bitmap.createBitmap(bm0.getWidth(), bm0.getHeight() + bm4.getHeight(), Bitmap.Config.ARGB_8888); 1979 Canvas graphCanvas = new Canvas(graph); 1980 graphCanvas.drawBitmap(bm4, 0, 0, null); 1981 graphCanvas.drawBitmap(bm0, 0, bm4.getHeight(), null); 1982 1983 String bitmapPath = MediaStore.Images.Media.insertImage(getContentResolver(), result, "First" + " - " + Calendar.getInstance().getTime(), null); 1984 Uri bitmapUri = Uri.parse(bitmapPath); 1985 1986 String bitmapPathTwo = MediaStore.Images.Media.insertImage(getContentResolver(), bm2, "Second" + " - " + Calendar.getInstance().getTime(), null); 1987 Uri bitmapUriTwo = Uri.parse(bitmapPathTwo); 1988 1989 String bitmapPathThree = MediaStore.Images.Media.insertImage(getContentResolver(), bm3, "Third" + " - " + Calendar.getInstance().getTime(), null); 1990 Uri bitmapUriThree = Uri.parse(bitmapPathThree); 1991 1992 String bitmapPathFour = MediaStore.Images.Media.insertImage(getContentResolver(), graph, "Four" + " - " + Calendar.getInstance().getTime(), null); 1993 Uri bitmapUriFour = Uri.parse(bitmapPathFour); 1994 1995 imageUriArray = new ArrayList(); 1996 imageUriArray.add(bitmapUri); 1997 imageUriArray.add(bitmapUriTwo); 1998 imageUriArray.add(bitmapUriThree); 1999 imageUriArray.add(bitmapUriFour); 2000 2001 intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, imageUriArray); 2002 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); 2003 intent.setType("image/png"); 2004 startActivity(intent); 2005 } 2006 2007 private boolean cycleThroughViews() { 2008 ConstraintLayout constraintLayout = findViewById(R.id.layout_result); 2009 if (constraintLayout == null) { 2010 return false; 2011 } 2012 bm1 = loadBitmapFromView(constraintLayout, true, false, false); 2013 ConstraintLayout constraintLayout0 = findViewById(R.id.title_bar); 2014 constraintLayout0.setVisibility(View.VISIBLE); 2015 bm0 = loadBitmapFromView(constraintLayout0, false, false, true); 2016 moreInfo(null); 2017 ConstraintLayout constraintLayout1 = findViewById(R.id.layout_more); 2018 bm2 = loadBitmapFromView(constraintLayout1, true, false, false); 2019 meg(null); 2020 ConstraintLayout constraintLayout2 = findViewById(R.id.layout_additional); 2021 bm3 = loadBitmapFromView(constraintLayout2, false, false, false); 2022 additionalAct(null); 2023 ConstraintLayout lineChartView = findViewById(R.id.constraintLayout); 2024 bm4 = loadBitmapFromView(lineChartView, false, true, false); 2025 meg(null); 2026 return true; 2027 } 2028 2029 public Bitmap loadBitmapFromView(View view, boolean f, boolean chart, boolean advertisement) { 2030 view.setLayoutParams(new 2031 ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, 2032 ConstraintLayout.LayoutParams.WRAP_CONTENT)); 2033 DisplayMetrics dm = this.getResources().getDisplayMetrics(); 2034 view.measure(View.MeasureSpec.makeMeasureSpec(dm.widthPixels, 2035 View.MeasureSpec.EXACTLY), 2036 View.MeasureSpec.makeMeasureSpec(dm.heightPixels, 2037 View.MeasureSpec.EXACTLY)); 2038 view.layout(0, 0, view.getMeasuredWidth(), chart ? view.getMeasuredWidth() : view.getMeasuredHeight()); 2039 if (advertisement) { 2040 Bitmap bitmap = Bitmap.createBitmap(view.getMeasuredWidth(), 240, 2041 Bitmap.Config.ARGB_8888); 2042 Canvas canvas = new Canvas(bitmap); 2043 view.layout(view.getLeft(), view.getTop(), view.getRight(), view.getBottom()); 2044 view.draw(canvas); 2045 return bitmap; 2046 } 2047 Bitmap bitmap = Bitmap.createBitmap(view.getMeasuredWidth(), chart ? view.getMeasuredWidth() : 2048 (int) (view.getMeasuredHeight() * (f ? (1.6 / (1.0 * view.getMeasuredHeight() / view.getMeasuredWidth())) : 1.0)), 2049 Bitmap.Config.ARGB_8888); 2050 Canvas canvas = new Canvas(bitmap); 2051 view.layout(view.getLeft(), view.getTop(), view.getRight(), view.getBottom()); 2052 view.draw(canvas); 2053 return bitmap; 2054 } 2055 2056 public void backToHome(View view) { 2057 setContentView(R.layout.splash_screen); 2058 ConstraintLayout constraintLayout = findViewById(R.id.root_splash); 2059 constraintLayout.setBackgroundColor(back_color); 2060 if (!(color_one == getColor(R.color.cyan) || color_two == getColor(R.color.pinkie))) { 2061 Button button = findViewById(R.id.button); 2062 Button button1 = findViewById(R.id.textView28); 2063 button.setBackgroundColor(color_one); 2064 button1.setBackgroundColor(color_one); 2065 Button button2 = findViewById(R.id.button2); 2066 Button button3 = findViewById(R.id.textView27); 2067 button2.setBackgroundColor(color_two); 2068 button3.setBackgroundColor(color_two); 2069 TextView logo_one = findViewById(R.id.logo_one); 2070 TextView logo_two = findViewById(R.id.logo_two); 2071 logo_one.setBackgroundColor(color_one); 2072 logo_two.setBackgroundColor(color_two); 2073 ConstraintLayout.LayoutParams params = (ConstraintLayout.LayoutParams) button.getLayoutParams(); 2074 params.setMargins(16, 0, 16, 24); 2075 button.setLayoutParams(params); 2076 params = (ConstraintLayout.LayoutParams) button1.getLayoutParams(); 2077 params.setMargins(16, 0, 16, 24); 2078 button1.setLayoutParams(params); 2079 params = (ConstraintLayout.LayoutParams) button2.getLayoutParams(); 2080 params.setMargins(16, 0, 16, 24); 2081 button2.setLayoutParams(params); 2082 params = (ConstraintLayout.LayoutParams) button3.getLayoutParams(); 2083 params.setMargins(16, 0, 16, 24); 2084 button3.setLayoutParams(params); 2085 } 2086 } 2087 2088 public void howTo(View view) { 2089 isHowToShown = true; 2090 setContentView(R.layout.activity_main); 2091 setContentView(R.layout.activity_main); 2092 } 2093 2094 public void openWhatsapp(View view) { 2095 Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.whatsapp"); 2096 if (launchIntent != null) { 2097 startActivity(launchIntent);//null pointer check in case package name was not found 2098 } else { 2099 Toast.makeText(this, "You do not have WhatsApp installed.", Toast.LENGTH_SHORT).show(); 2100 } 2101 } 2102 2103 public void switchGraph(View view) { 2104 BarChart barChart = findViewById(R.id.ColumnChartView); 2105 LineChartView lineChartView = findViewById(R.id.LineChartView); 2106 if (activeGraph > 0) { 2107 barChart.setVisibility(View.INVISIBLE); 2108 lineChartView.setVisibility(View.VISIBLE); 2109 activeGraph = -1; 2110 } else { 2111 barChart.setVisibility(View.VISIBLE); 2112 lineChartView.setVisibility(View.INVISIBLE); 2113 activeGraph = 1; 2114 } 2115 } 2116 2117 public void openSettingsActivity(View view) { 2118 Intent intent = new Intent(this, SettingsActivity.class); 2119 startActivity(intent); 2120 } 2121 2122 public void openWebsite(View view) { 2123 String url = "http://www.asimplesock.com/chatistics.html"; 2124 Intent i = new Intent(this,WebViewActivity.class); 2125 i.putExtra("link",url); 2126 startActivity(i); 2127 } 2128 2129 public void shareChatistics(View view) { 2130 Intent i = new Intent(android.content.Intent.ACTION_SEND); 2131 i.setType("text/plain"); 2132 i.putExtra(android.content.Intent.EXTRA_TEXT, "Chatistics: WhatsApp Chat Statistics\nOpen Source, Works Offline and No Permissions!\nhttps://play.google.com/store/apps/details?id=com.asimplesock.chatstatistics"); 2133 startActivity(i); 2134 } 2135 2136 public void shareGroup(View view) { 2137 ConstraintLayout constraintLayout = findViewById(R.id.group); 2138 Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE); 2139 Bitmap group = loadBitmapFromView(constraintLayout, false, false, false); 2140 ConstraintLayout constraintLayout0 = findViewById(R.id.title_bar); 2141 constraintLayout0.setVisibility(View.VISIBLE); 2142 bm0 = loadBitmapFromView(constraintLayout0, false, false, true); 2143 2144 Bitmap result = Bitmap.createBitmap(bm0.getWidth(), group.getHeight(), Bitmap.Config.ARGB_8888); 2145 Canvas graphCanvas = new Canvas(result); 2146 graphCanvas.drawBitmap(bm0, 0, 0, null); 2147 graphCanvas.drawBitmap(group, 0, bm0.getHeight(), null); 2148 2149 2150 String bitmapPath = MediaStore.Images.Media.insertImage(getContentResolver(), result, "First" + " - " + Calendar.getInstance().getTime(), null); 2151 Uri bitmapUri = Uri.parse(bitmapPath); 2152 imageUriArray = new ArrayList(); 2153 imageUriArray.add(bitmapUri); 2154 intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, imageUriArray); 2155 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); 2156 intent.setType("image/png"); 2157 //intent.putExtra(Intent.EXTRA_TEXT, "Download Chatistics!!\nhttps://play.google.com/store/apps/details?id=com.asimplesock.chatstatistics"); 2158 //intent.setType("text/plain"); 2159 startActivity(intent); 2160 } 2161 2162 public void shareSingle(View view) { 2163 LinearLayout names = findViewById(R.id.linearLayout); 2164 names.setBackgroundColor(back_color); 2165 bmNames = Bitmap.createBitmap(names.getWidth(), names.getHeight(), Bitmap.Config.ARGB_8888); 2166 Canvas namesCanvas = new Canvas(bmNames); 2167 names.draw(namesCanvas); 2168 ConstraintLayout constraintLayout = findViewById(R.id.layout_result); 2169 bm1 = Bitmap.createBitmap(constraintLayout.getWidth(), constraintLayout.getHeight(), Bitmap.Config.ARGB_8888); 2170 Canvas c1 = new Canvas(bm1); 2171 constraintLayout.draw(c1); 2172 ConstraintLayout constraintLayout0 = findViewById(R.id.title_bar_ad); 2173 constraintLayout0.setVisibility(View.VISIBLE); 2174 bm0 = Bitmap.createBitmap(constraintLayout0.getWidth(), constraintLayout0.getHeight(), Bitmap.Config.ARGB_8888); 2175 Canvas c0 = new Canvas(bm0); 2176 constraintLayout0.draw(c0); 2177 constraintLayout0.setVisibility(View.GONE); 2178 ConstraintLayout constraintLayout1 = findViewById(R.id.layout_more); 2179 bm2 = Bitmap.createBitmap(constraintLayout1.getWidth(), constraintLayout1.getHeight(), Bitmap.Config.ARGB_8888); 2180 Canvas c2 = new Canvas(bm2); 2181 constraintLayout1.draw(c2); 2182 ConstraintLayout constraintLayout2 = findViewById(R.id.layout_additional); 2183 bm3 = Bitmap.createBitmap(constraintLayout2.getWidth(), constraintLayout2.getHeight(), Bitmap.Config.ARGB_8888); 2184 Canvas c3 = new Canvas(bm3); 2185 constraintLayout2.draw(c3); 2186 BarChart lineChartView = findViewById(R.id.ColumnChartView); 2187 Bitmap bitmap = Bitmap.createBitmap(lineChartView.getWidth(), lineChartView.getHeight(), 2188 Bitmap.Config.ARGB_8888); 2189 Canvas canvasa = new Canvas(bitmap); 2190 lineChartView.layout(lineChartView.getLeft(), lineChartView.getTop(), lineChartView.getRight(), lineChartView.getBottom()); 2191 lineChartView.draw(canvasa); 2192 bm4 = bitmap; 2193 // bm4 = loadBitmapFromView(lineChartView, false, true, false); 2194 Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE); 2195 2196 Bitmap result = Bitmap.createBitmap(bm0.getWidth(), bm0.getHeight() + bm1.getHeight(), Bitmap.Config.ARGB_8888); 2197 Canvas canvas = new Canvas(result); 2198 canvas.drawBitmap(bm0, 0, 0, null); 2199 canvas.drawBitmap(bm1, 0, bm0.getHeight(), null); 2200 2201 Bitmap secondResult = Bitmap.createBitmap(bm0.getWidth(), bmNames.getHeight() + bm2.getHeight(), Bitmap.Config.ARGB_8888); 2202 Canvas secondCanvas = new Canvas(secondResult); 2203 secondCanvas.drawBitmap(bmNames, 0, 0, null); 2204 secondCanvas.drawBitmap(bm2, 0, bmNames.getHeight(), null); 2205 2206 Bitmap graph = Bitmap.createBitmap(bm0.getWidth(), bm0.getHeight() + bm4.getHeight(), Bitmap.Config.ARGB_8888); 2207 Canvas graphCanvas = new Canvas(graph); 2208 graphCanvas.drawBitmap(bm4, 0, 0, null); 2209 graphCanvas.drawBitmap(bm0, 0, bm4.getHeight(), null); 2210 2211 String bitmapPath = MediaStore.Images.Media.insertImage(getContentResolver(), result, "First" + " - " + Calendar.getInstance().getTime(), null); 2212 Uri bitmapUri = Uri.parse(bitmapPath); 2213 2214 String bitmapPathTwo = MediaStore.Images.Media.insertImage(getContentResolver(), secondResult, "Second" + " - " + Calendar.getInstance().getTime(), null); 2215 Uri bitmapUriTwo = Uri.parse(bitmapPathTwo); 2216 2217 String bitmapPathThree = MediaStore.Images.Media.insertImage(getContentResolver(), bm3, "Third" + " - " + Calendar.getInstance().getTime(), null); 2218 Uri bitmapUriThree = Uri.parse(bitmapPathThree); 2219 2220 String bitmapPathFour = MediaStore.Images.Media.insertImage(getContentResolver(), graph, "Four" + " - " + Calendar.getInstance().getTime(), null); 2221 Uri bitmapUriFour = Uri.parse(bitmapPathFour); 2222 2223 imageUriArray = new ArrayList(); 2224 imageUriArray.add(bitmapUri); 2225 imageUriArray.add(bitmapUriTwo); 2226 imageUriArray.add(bitmapUriThree); 2227 imageUriArray.add(bitmapUriFour); 2228 2229 intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, imageUriArray); 2230 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); 2231 intent.setType("image/png"); 2232 startActivity(intent); 2233 } 2234 2235 public double[] getRatio() { 2236 double[] i = {this.mTexts1, this.mTexts2}; 2237 if (i[1] > i[0]) { 2238 i[1] = i[1] / i[0]; 2239 i[0] = 1.0D; 2240 } else { 2241 i[0] = i[0] / i[1]; 2242 i[1] = 1.0D; 2243 } 2244 return i; 2245 } 2246 2247 public void showDemo(View view) { 2248 setContentView(R.layout.activity_main); 2249 try { 2250 if (parse()) { 2251 setContentView(R.layout.activity_group); 2252 TextView key1 = findViewById(R.id.key1); 2253 TextView key2 = findViewById(R.id.key2); 2254 TextView key3 = findViewById(R.id.key3); 2255 TextView key4 = findViewById(R.id.key4); 2256 TextView key5 = findViewById(R.id.key5); 2257 TextView textView48 = findViewById(R.id.textView48); 2258 TextView textView59 = findViewById(R.id.textView59); 2259 TextView textView95 = findViewById(R.id.textView95); 2260 TextView textView99 = findViewById(R.id.textView99); 2261 TextView textView100 = findViewById(R.id.textView100); 2262 TextView textView103 = findViewById(R.id.textView103); 2263 textView59.setText(("" + 5)); 2264 textView95.setText(("" + 2380)); 2265 textView48.setText(("Group Name")); 2266 textView99.setText(("firstDate")); 2267 textView100.setText(("creator")); 2268 rName1 = "Group"; 2269 name1 = "Group Name"; 2270 name2 = "Person 1"; 2271 ColumnChartView columnChartView = findViewById(R.id.columnChartView); 2272 List<Column> columns = new ArrayList<>(); 2273 List<SubcolumnValue> values; 2274 values = new ArrayList<>(); 2275 values.add(new SubcolumnValue(1080, getColor(R.color.Lred))); 2276 values.add(new SubcolumnValue(720, getColor(R.color.Lorange))); 2277 values.add(new SubcolumnValue(480, getColor(R.color.Lblue))); 2278 values.add(new SubcolumnValue(360, getColor(R.color.Lyellow))); 2279 values.add(new SubcolumnValue(240, getColor(R.color.Lgreen))); 2280 key1.setText((" " + "One")); 2281 key2.setText((" " + "Two")); 2282 key3.setText((" " + "Three")); 2283 key4.setText((" " + "Four")); 2284 key5.setText((" " + "Five")); 2285 Column column = new Column(values); 2286 column.setHasLabels(true); 2287 columns.add(column); 2288 columnChartView.setColumnChartData(new ColumnChartData(columns)); 2289 textView103.setText(("23.5")); 2290 } 2291 } catch (Exception e) { 2292 e.printStackTrace(); 2293 } 2294 } 2295 2296 public void hideStatusBar() { 2297 View decorView = getWindow().getDecorView(); 2298 int uiOptions = 4; 2299 decorView.setSystemUiVisibility(uiOptions); 2300 } 2301 2302 public void showSample(View view) { 2303 setContentView(R.layout.activity_main); 2304 final VideoView videoView = findViewById(R.id.videoView1); 2305 videoView.setVisibility(View.VISIBLE); 2306 MediaController mediaController = new MediaController(this); 2307 mediaController.setAnchorView(videoView); 2308 String uriPath = "android.resource://" + getPackageName() + "/" + R.raw.demo; 2309 Uri uri = Uri.parse(uriPath); 2310 videoView.setMediaController(mediaController); 2311 videoView.setVideoURI(uri); 2312 videoView.requestFocus(); 2313 videoView.start(); 2314 videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { 2315 public void onCompletion(MediaPlayer mp) { 2316 videoView.setVisibility(View.INVISIBLE); 2317 setContentView(R.layout.splash_screen); 2318 } 2319 }); 2320 2321 videoView.setOnClickListener(new View.OnClickListener() { 2322 public void onClick(View v) { 2323 videoView.setVisibility(View.INVISIBLE); 2324 videoView.stopPlayback(); 2325 setContentView(R.layout.splash_screen); 2326 } 2327 }); 2328 } 2329 2330 private int timeDiff(String a, String b) { 2331 int diff = 0; 2332 try { 2333 int aHour = Integer.parseInt(a.substring(0, a.indexOf(":"))); 2334 int bHour = Integer.parseInt(b.substring(0, b.indexOf(":"))); 2335 int aMin = Integer.parseInt(a.substring(a.indexOf(":") + 1)); 2336 int bMin = Integer.parseInt(b.substring(b.indexOf(":") + 1)); 2337 if (aHour == bHour) { 2338 diff = bMin - aMin; 2339 if (diff < 0) { 2340 diff = 1000; 2341 } 2342 } else { 2343 if (bHour - aHour == 1) { 2344 2345 } 2346 } 2347 } catch (Exception e) { 2348 e.printStackTrace(); 2349 } 2350 return diff; 2351 } 2352 2353 private void init() { 2354 reviewManager = ReviewManagerFactory.create(this); 2355 showRateApp(); 2356 } 2357 2358 /** 2359 * Shows rate app bottom sheet using In-App review API 2360 * The bottom sheet might or might not shown depending on the Quotas and limitations 2361 * https://developer.android.com/guide/playcore/in-app-review#quotas 2362 * We show fallback dialog if there is any error 2363 */ 2364 public void showRateApp() { 2365 Task<ReviewInfo> request = reviewManager.requestReviewFlow(); 2366 request.addOnCompleteListener(task -> { 2367 if (task.isSuccessful()) { 2368 // We can get the ReviewInfo object 2369 ReviewInfo reviewInfo = task.getResult(); 2370 2371 Task<Void> flow = reviewManager.launchReviewFlow(this, reviewInfo); 2372 flow.addOnCompleteListener(task1 -> { 2373 // The flow has finished. The API does not indicate whether the user 2374 // reviewed or not, or even whether the review dialog was shown. Thus, no 2375 // matter the result, we continue our app flow. 2376 }); 2377 } else { 2378 // There was some problem, continue regardless of the result. 2379 // show native rate app dialog on error 2380 } 2381 }); 2382 } 2383 2384 public void redirectToPlayStore() { 2385 final String appPackageName = getPackageName(); 2386 try { 2387 startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName))); 2388 } catch (ActivityNotFoundException exception) { 2389 startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName))); 2390 } 2391 } 2392 2393 private class MoreAsyncTask extends AsyncTask<Void, Void, Void> { 2394 private MoreAsyncTask() { 2395 } 2396 2397 protected Void doInBackground(Void... voids) { 2398 MainActivity.this.moreData = new MoreData(1.0D, 1.0D, 1.0D * MainActivity.this.mWords1 / MainActivity.this.mTexts1, 1.0D * MainActivity.this.mWords2 / MainActivity.this.mTexts2); 2399 MainActivity.this.findPerTimesTextedFirst(MainActivity.this.moreData); 2400 MainActivity.this.DaysBetween = MainActivity.this.getTotalDays(); 2401 MainActivity.this.moreData.setAvgTexts1(1.0D * MainActivity.this.mTexts1 / MainActivity.this.DaysBetween); 2402 MainActivity.this.moreData.setAvgTexts2(1.0D * MainActivity.this.mTexts2 / MainActivity.this.DaysBetween); 2403 return null; 2404 } 2405 2406 protected void onPostExecute(Void aVoid) { 2407 try { 2408 LinearLayout linearLayout = MainActivity.this.findViewById(R.id.linearLayout); 2409 linearLayout.setVisibility(View.VISIBLE); 2410 TextView textView6 = MainActivity.this.findViewById(R.id.textView6); 2411 textView6.setText((MainActivity.this.DaysBetween + "")); 2412 TextView textView4 = findViewById(R.id.textView4); 2413 textView4.setText(getFirstMsg()); 2414 int hours = minutesSpent / 60; 2415 int minutes = minutesSpent % 60; 2416 TextView textViewTime = findViewById(R.id.textViewTime); 2417 textViewTime.setTypeface(getResources().getFont(R.font.chinkala)); 2418 TextView textViewTimeH = findViewById(R.id.textViewTimeH); 2419 textViewTimeH.setTypeface(getResources().getFont(R.font.chinkala)); 2420 textViewTime.setText((hours + " hours " + minutes + " minutes")); 2421 if (dateError) { 2422 textView4.setText(getFirstMsg()); 2423 } 2424 ConstraintLayout constraintLayout = findViewById(R.id.loading); 2425 if (!single) 2426 constraintLayout.setVisibility(View.INVISIBLE); 2427 } catch (Exception e) { 2428 } 2429 } 2430 } 2431 2432 private class MostCommonASyncTask extends AsyncTask<Void, Void, Void> { 2433 private MostCommonASyncTask() { 2434 } 2435 2436 protected Void doInBackground(Void... voids) { 2437 MainActivity.this.dirtyMethod(); 2438 return null; 2439 } 2440 2441 protected void onPostExecute(Void aVoid) { 2442 MainActivity.this.processed = true; 2443 if (single) { 2444 moreInfo(null); 2445 meg(null); 2446 finalAct(null); 2447 } else { 2448 LinearLayout linearLayout3 = MainActivity.this.findViewById(R.id.linearLayout3); 2449 linearLayout3.setVisibility(View.VISIBLE); 2450 ProgressBar progressBar = findViewById(R.id.more_progress_bar); 2451 progressBar.setVisibility(View.INVISIBLE); 2452 ImageView imageView = findViewById(R.id.share_button); 2453 imageView.setVisibility(View.VISIBLE); 2454 ProgressBar progressBar1 = findViewById(R.id.share_button_progress_bar); 2455 progressBar1.setVisibility(View.INVISIBLE); 2456 if (shareAvailable) { 2457 if (cycleThroughViews()) 2458 shareImageUri(); 2459 onBackPressed(); 2460 } 2461 } 2462 2463 } 2464 } 2465 2466 private class AnotherASyncTask extends AsyncTask<Void, Void, Void> { 2467 private AnotherASyncTask() { 2468 } 2469 2470 @RequiresApi(api = Build.VERSION_CODES.M) 2471 protected Void doInBackground(Void... voids) { 2472 MainActivity.this.calculateChart(); 2473 return null; 2474 } 2475 2476 protected void onPostExecute(Void aVoid) { 2477 MainActivity.this.anotherProcessed = true; 2478 if (single) { 2479 additionalAct(null); 2480 switchGraph(null); 2481 switchGraph(null); 2482 } 2483 } 2484 } 2485 } 2486