Skip to content

Commit

Permalink
Fixed an issue where on higher build versions deleting the app didn't…
Browse files Browse the repository at this point in the history
… actually reset the data, so I made it less awful and just added a menu button. I also have now added chrome custom tabs for most things which is nice.
  • Loading branch information
Github committed May 7, 2017
1 parent cc8de43 commit 7e05edf
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ dependencies {


compile 'com.android.volley:volley:1.0.0'
compile 'org.java-websocket:Java-WebSocket:1.3.0'
compile 'com.github.stfalcon:chatkit:0.2.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.google.firebase:firebase-core:10.2.1'
compile 'com.google.firebase:firebase-crash:10.2.1'
compile 'com.github.javiersantos:AppUpdater:2.6.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.google.firebase:firebase-messaging:10.2.1'
compile 'com.android.support:customtabs:25.0.1'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
62 changes: 60 additions & 2 deletions app/src/main/java/eu/aero2x/andromedab/ContactSelect.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.support.customtabs.CustomTabsIntent;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.InputType;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
Expand Down Expand Up @@ -92,7 +96,7 @@ protected void onCreate(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
//you should edit this to fit your needs
builder.setTitle("Andromeda Configuration");
builder.setMessage("To use Andromeda you must have a server running OSXMessageProxy. \n\nMake sure that all the data you enter is correct because it will not be validated and you will have to delete and re-install the app to reconfigure");
builder.setMessage("To use Andromeda you must have a server running OSXMessageProxy. \n\nIf you make a mistake, open the menu up top and choose 'Reset configuration...'");

final EditText apiIPEndPoint = new EditText(this);
apiIPEndPoint.setHint("your.domain.com or 182.123.321.164");
Expand Down Expand Up @@ -144,7 +148,7 @@ public void onClick(DialogInterface dialog, int whichButton) {

builder.setNegativeButton("Exit", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
finish();
finishAffinity();
}
});
builder.show();
Expand All @@ -154,7 +158,61 @@ public void onClick(DialogInterface dialog, int whichButton) {
}
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_conversations, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
switch (item.getItemId()) {
case R.id.resetConfig:
AlertDialog alertDialog = new AlertDialog.Builder(ContactSelect.this).create();
alertDialog.setTitle("Are you sure you want to reset the application?");
alertDialog.setMessage("This will remove the entire application configuration and close the application.");
alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, "Reset",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Bundle bundle = new Bundle();
bundle.putString(FirebaseAnalytics.Param.VALUE, "Erased settings");
mFirebaseAnalytics.logEvent("app_menu_reset_settings", bundle);
SharedPreferences.Editor editor = getSharedPreferences("CONFIG", MODE_PRIVATE).edit();
//Nuke all preferences
editor.putString("apiIPEndpoint",null);
editor.putInt("apiPort",0);
editor.putInt("socketPort",0);
//Force safe instantly.
editor.commit();
//Close the activity
finishAffinity();
//Kill ourselves so that it's a completely clean state.
System.exit(0);
}
});
alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, "Cancel",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Bundle bundle = new Bundle();
bundle.putString(FirebaseAnalytics.Param.VALUE, "Erase settings canceled");
mFirebaseAnalytics.logEvent("app_menu", bundle);
dialog.dismiss();
}
});
alertDialog.show();
return true;
case R.id.openProjectPage:
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.launchUrl(ContactSelect.this, Uri.parse("https://github.com/shusain93/Andromeda-iMessage"));

return true;
default:
return super.onOptionsItemSelected(item);
}
}

private void prepareView() {
//Prepare our APP_CONSTANTS
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/java/eu/aero2x/andromedab/Conversation.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.content.ClipboardManager;
import android.content.Intent;
import android.net.Uri;
import android.support.customtabs.CustomTabsIntent;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
Expand Down Expand Up @@ -448,8 +449,9 @@ public void onMessageClick(CustomMessage message) {
bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, "Tapped image to launch it in browser");
mFirebaseAnalytics.logEvent("message_image_tap", bundle);
//We have an image. They've tapped the image so we want to open it in the browser
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(imageUrlIfExsists));
startActivity(browserIntent);
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.launchUrl(Conversation.this, Uri.parse(imageUrlIfExsists));
}
}
}
9 changes: 9 additions & 0 deletions app/src/main/res/menu/menu_conversations.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/openProjectPage"
android:title="Open project page"
android:showAsAction="ifRoom"/>
<item android:id="@+id/resetConfig"
android:title="Reset configuration..."
android:showAsAction="ifRoom"/>
</menu>

0 comments on commit 7e05edf

Please sign in to comment.