Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified .gitignore
100644 → 100755
Empty file.
Empty file modified .idea/compiler.xml
100644 → 100755
Empty file.
Empty file modified .idea/copyright/profiles_settings.xml
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion .idea/gradle.xml
100644 → 100755

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 1 addition & 14 deletions .idea/misc.xml
100644 → 100755

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file modified .idea/modules.xml
100644 → 100755
Empty file.
Empty file modified .idea/runConfigurations.xml
100644 → 100755
Empty file.
Empty file modified .idea/vcs.xml
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
Empty file modified app/.gitignore
100644 → 100755
Empty file.
Binary file added app/app-release.apk
Binary file not shown.
6 changes: 3 additions & 3 deletions app/build.gradle
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.tobedecided.dynamicdialer"
minSdkVersion 16
targetSdkVersion 25
versionCode 2
versionName "1.1"
versionCode 3
versionName "1.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand Down
Empty file modified app/proguard-rules.pro
100644 → 100755
Empty file.
Empty file.
Empty file modified app/src/main/AndroidManifest.xml
100644 → 100755
Empty file.
Empty file.
Empty file modified app/src/main/java/com/tobedecided/dynamicdialer/Constants.java
100644 → 100755
Empty file.
Empty file.
Empty file.
Empty file modified app/src/main/java/com/tobedecided/dynamicdialer/GsonModels.java
100644 → 100755
Empty file.
Empty file.
Empty file modified app/src/main/java/com/tobedecided/dynamicdialer/Log.java
100644 → 100755
Empty file.
Empty file.
Empty file.
77 changes: 49 additions & 28 deletions app/src/main/java/com/tobedecided/dynamicdialer/MainActivity.java
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.tobedecided.dynamicdialer;

import android.app.LoaderManager;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.CursorLoader;
import android.content.Intent;
Expand Down Expand Up @@ -35,6 +36,9 @@ public class MainActivity extends AppCompatActivity implements LoaderManager.Loa
private Toolbar toolbar;
private TabLayout tabLayout;
private ViewPager viewPager;
private boolean firstLaunch;
public ProgressDialog progressDialog;


public static long getContactIDFromNumber(String contactNumber, Context context) {
Uri uri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI,
Expand All @@ -56,7 +60,7 @@ public static long getContactIDFromNumber(String contactNumber, Context context)
return contactId.equals("") ? 0 : Long.parseLong(contactId);
}

public static void sendLogs(String body, final SharedPreferences sharedPreferences) {
public void sendLogs(String body, final SharedPreferences sharedPreferences) {
RequestBody requestBody = RequestBody.create(okhttp3.MediaType.parse("application/json; charset=utf-8"), body);
RetrofitInterface retrofitInterface = ServiceGenerator.createService(RetrofitInterface.class);
retrofitInterface.sendSource("application/json", "bhavesh2109", "b5265ab5defd322e797052263c4f04e1bcb53d42", requestBody).enqueue(new Callback<GsonModels.BigMLSourceResponse>() {
Expand Down Expand Up @@ -87,6 +91,8 @@ public void onResponse(Call<GsonModels.BigMLModelResponse> call, Response<GsonMo
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString("resource2", resource2);
editor.apply();

progressDialog.setMessage("Training your machine learning model...\nThis may take a few minutes during the first launch.");
}
}

Expand Down Expand Up @@ -135,6 +141,21 @@ public void onClick(View view) {
}
});
getLoaderManager().initLoader(URL_LOADER, null, MainActivity.this);

SharedPreferences sharedPreferences = getSharedPreferences("DynamicDialer", Context.MODE_PRIVATE);
firstLaunch = sharedPreferences.getBoolean("FirstLaunch", true);

progressDialog = new ProgressDialog(this, R.style.AppCompatAlertDialogStyle);
progressDialog.setIndeterminate(true);
progressDialog.setMessage("Fetching Logs...");
progressDialog.setCancelable(false);

if (firstLaunch) {
progressDialog.show();
SharedPreferences.Editor editor = getSharedPreferences("DynamicDialer", Context.MODE_PRIVATE).edit();
editor.putBoolean("FirstLaunch", false);
editor.apply();
}
}

private void setupViewPager(ViewPager viewPager) {
Expand All @@ -144,33 +165,33 @@ private void setupViewPager(ViewPager viewPager) {
viewPager.setAdapter(adapter);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();

//noinspection SimplifiableIfStatement
if (id == R.id.action_about) {
Intent intent = new Intent(MainActivity.this, AboutActivity.class);
startActivity(intent);
return true;
} else if (id == R.id.action_privacy) {
Intent intent = new Intent(MainActivity.this, PrivacyActivity.class);
startActivity(intent);
return true;
}

return super.onOptionsItemSelected(item);
}
// @Override
// public boolean onCreateOptionsMenu(Menu menu) {
// // Inflate the menu; this adds items to the action bar if it is present.
// getMenuInflater().inflate(R.menu.menu_main, menu);
// return true;
// }

// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// // Handle action bar item clicks here. The action bar will
// // automatically handle clicks on the Home/Up button, so long
// // as you specify a parent activity in AndroidManifest.xml.
// int id = item.getItemId();
//
// //noinspection SimplifiableIfStatement
// if (id == R.id.action_about) {
// Intent intent = new Intent(MainActivity.this, AboutActivity.class);
// startActivity(intent);
// return true;
// } else if (id == R.id.action_privacy) {
// Intent intent = new Intent(MainActivity.this, PrivacyActivity.class);
// startActivity(intent);
// return true;
// }
//
// return super.onOptionsItemSelected(item);
// }

@Override
public android.content.Loader<Cursor> onCreateLoader(int id, Bundle args) {
Expand Down
Empty file modified app/src/main/java/com/tobedecided/dynamicdialer/Prediction.java
100644 → 100755
Empty file.
Empty file.
22 changes: 18 additions & 4 deletions app/src/main/java/com/tobedecided/dynamicdialer/PredictionsFragment.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import okhttp3.RequestBody;
import retrofit2.Call;
Expand Down Expand Up @@ -131,7 +133,7 @@ public Loader<Cursor> onCreateLoader(int id, Bundle args) {
case URL_LOADER:
// Returns a new CursorLoader
return new CursorLoader(
getContext(), // Parent activity context
getActivity(), // Parent activity context
CallLog.Calls.CONTENT_URI, // Table to query
null, // Projection to return
null, // No selection clause
Expand All @@ -143,8 +145,13 @@ public Loader<Cursor> onCreateLoader(int id, Bundle args) {
}
}


@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
if (data.isClosed()) {
onStart();
return;
}
int name = data.getColumnIndex(CallLog.Calls.CACHED_NAME);
int number = data.getColumnIndex(CallLog.Calls.NUMBER);
int type = data.getColumnIndex(CallLog.Calls.TYPE);
Expand Down Expand Up @@ -214,7 +221,8 @@ public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
sb.append("\"}");

SharedPreferences sharedPreferences = getContext().getSharedPreferences("DynamicDialer", Context.MODE_PRIVATE);
MainActivity.sendLogs(sb.toString(), sharedPreferences);
((MainActivity)getActivity()).sendLogs(sb.toString(), sharedPreferences);
((MainActivity)getActivity()).progressDialog.dismiss();
}

@Override
Expand Down Expand Up @@ -279,9 +287,15 @@ public void displayPredictions(GsonModels.BigMLPredictionsResponse bigMLPredicti
if (probabilities == null)
return;
predictionList = new ArrayList<>();
Map<String, Boolean> map = new HashMap<String, Boolean>();
for (int i = 0; i < probabilities.size(); i++) {
if (!(getContactName(getContext(), probabilities.get(i).get(0)) == null) && !getContactName(getContext(), probabilities.get(i).get(0)).isEmpty())
predictionList.add(new Prediction(getContactIDFromNumber(probabilities.get(i).get(1), getContext()), getContactName(getContext(), probabilities.get(i).get(0)), probabilities.get(i).get(0), Double.parseDouble(probabilities.get(i).get(1))));
if (!(getContactName(getContext(), probabilities.get(i).get(0)) == null) && !getContactName(getContext(), probabilities.get(i).get(0)).isEmpty()) {
String contactNumber = probabilities.get(i).get(0);
if(!map.containsKey(contactNumber)) {
map.put(contactNumber, true);
predictionList.add(new Prediction(getContactIDFromNumber(probabilities.get(i).get(1), getContext()), getContactName(getContext(), probabilities.get(i).get(0)), probabilities.get(i).get(0), Double.parseDouble(probabilities.get(i).get(1))));
}
}
}
Collections.sort(predictionList, Prediction.Comparators.PROBABILITY);
predictionsAdapter = new PredictionsAdapter(predictionList, getActivity(), new ItemClickListener() {
Expand Down
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file modified app/src/main/res/drawable-hdpi/app_icon.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified app/src/main/res/drawable-hdpi/ic_backspace_black_24dp.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified app/src/main/res/drawable-hdpi/ic_call_black_24dp.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified app/src/main/res/drawable-hdpi/ic_call_white_48dp.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified app/src/main/res/drawable-hdpi/ic_dialpad_white_48dp.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified app/src/main/res/drawable-hdpi/ic_more_vert_white_24dp.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified app/src/main/res/drawable-mdpi/app_icon.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified app/src/main/res/drawable-mdpi/ic_backspace_black_24dp.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified app/src/main/res/drawable-mdpi/ic_call_black_24dp.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified app/src/main/res/drawable-mdpi/ic_call_white_48dp.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified app/src/main/res/drawable-mdpi/ic_dialpad_white_48dp.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified app/src/main/res/drawable-mdpi/ic_more_vert_white_24dp.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified app/src/main/res/drawable-xhdpi/app_icon.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified app/src/main/res/drawable-xhdpi/ic_backspace_black_24dp.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified app/src/main/res/drawable-xhdpi/ic_call_black_24dp.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified app/src/main/res/drawable-xhdpi/ic_call_white_48dp.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified app/src/main/res/drawable-xhdpi/ic_dialpad_white_48dp.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified app/src/main/res/drawable-xhdpi/ic_more_vert_white_24dp.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified app/src/main/res/drawable-xxhdpi/app_icon.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified app/src/main/res/drawable-xxhdpi/ic_backspace_black_24dp.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified app/src/main/res/drawable-xxhdpi/ic_call_black_24dp.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified app/src/main/res/drawable-xxhdpi/ic_call_white_48dp.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified app/src/main/res/drawable-xxhdpi/ic_dialpad_white_48dp.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified app/src/main/res/drawable-xxhdpi/ic_more_vert_white_24dp.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified app/src/main/res/drawable-xxxhdpi/app_icon.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified app/src/main/res/drawable-xxxhdpi/ic_backspace_black_24dp.png
100644 → 100755
Empty file modified app/src/main/res/drawable-xxxhdpi/ic_call_black_24dp.png
100644 → 100755
Empty file modified app/src/main/res/drawable-xxxhdpi/ic_call_white_48dp.png
100644 → 100755
Empty file modified app/src/main/res/drawable-xxxhdpi/ic_dialpad_white_48dp.png
100644 → 100755
Empty file modified app/src/main/res/drawable-xxxhdpi/ic_more_vert_white_24dp.png
100644 → 100755
Empty file modified app/src/main/res/drawable/splash.png
100644 → 100755
Empty file modified app/src/main/res/layout/activity_about.xml
100644 → 100755
Empty file.
Empty file modified app/src/main/res/layout/activity_dialpad.xml
100644 → 100755
Empty file.
Empty file modified app/src/main/res/layout/activity_main.xml
100644 → 100755
Empty file.
Empty file modified app/src/main/res/layout/activity_privacy.xml
100644 → 100755
Empty file.
Empty file modified app/src/main/res/layout/content_dialpad.xml
100644 → 100755
Empty file.
Empty file modified app/src/main/res/layout/content_main.xml
100644 → 100755
Empty file.
Empty file modified app/src/main/res/layout/digit_layout.xml
100644 → 100755
Empty file.
Empty file modified app/src/main/res/layout/fragment_logs.xml
100644 → 100755
Empty file.
Empty file modified app/src/main/res/layout/fragment_predictions.xml
100644 → 100755
Empty file.
Empty file modified app/src/main/res/layout/log_list_row.xml
100644 → 100755
Empty file.
Empty file modified app/src/main/res/layout/prediction_list_row.xml
100644 → 100755
Empty file.
20 changes: 10 additions & 10 deletions app/src/main/res/menu/menu_main.xml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.tobedecided.dynamicdialer.MainActivity">
<item
android:id="@+id/action_about"
android:orderInCategory="100"
android:title="@string/action_about"
app:showAsAction="never" />
<!--<item-->
<!--android:id="@+id/action_about"-->
<!--android:orderInCategory="100"-->
<!--android:title="@string/action_about"-->
<!--app:showAsAction="never" />-->

<item
android:id="@+id/action_privacy"
android:orderInCategory="50"
android:title="@string/action_privacy"
app:showAsAction="never" />
<!--<item-->
<!--android:id="@+id/action_privacy"-->
<!--android:orderInCategory="50"-->
<!--android:title="@string/action_privacy"-->
<!--app:showAsAction="never" />-->
</menu>
Empty file modified app/src/main/res/mipmap-hdpi/ic_launcher.png
100644 → 100755
Empty file modified app/src/main/res/mipmap-mdpi/ic_launcher.png
100644 → 100755
Empty file modified app/src/main/res/mipmap-xhdpi/ic_launcher.png
100644 → 100755
Empty file modified app/src/main/res/mipmap-xxhdpi/ic_launcher.png
100644 → 100755
Empty file modified app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
100644 → 100755
Empty file modified app/src/main/res/values-v21/styles.xml
100644 → 100755
Empty file.
Empty file modified app/src/main/res/values-w820dp/dimens.xml
100644 → 100755
Empty file.
Empty file modified app/src/main/res/values/colors.xml
100644 → 100755
Empty file.
Empty file modified app/src/main/res/values/dimens.xml
100644 → 100755
Empty file.
Empty file modified app/src/main/res/values/strings.xml
100644 → 100755
Empty file.
6 changes: 6 additions & 0 deletions app/src/main/res/values/styles.xml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,10 @@
<item name="android:windowBackground">@drawable/splash</item>
</style>

<style name="AppCompatAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="colorAccent">@android:color/black</item>
<item name="android:textColorPrimary">@android:color/darker_gray</item>
<item name="android:background">@android:color/white</item>
</style>

</resources>
Empty file.
4 changes: 3 additions & 1 deletion build.gradle
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'com.android.tools.build:gradle:3.0.0-beta6'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -15,6 +16,7 @@ buildscript {
allprojects {
repositories {
jcenter()
google()
}
}

Expand Down
Empty file modified gradle.properties
100644 → 100755
Empty file.
Empty file modified gradle/wrapper/gradle-wrapper.jar
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Dec 28 10:00:20 PST 2015
#Sun Oct 08 14:07:57 IST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
Empty file modified gradlew.bat
100644 → 100755
Empty file.
Empty file modified settings.gradle
100644 → 100755
Empty file.