Skip to content

Commit 7e05edf

Browse files
author
Github
committed
Fixed an issue where on higher build versions deleting the app didn't 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.
1 parent cc8de43 commit 7e05edf

File tree

4 files changed

+74
-5
lines changed

4 files changed

+74
-5
lines changed

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ dependencies {
3333

3434

3535
compile 'com.android.volley:volley:1.0.0'
36-
compile 'org.java-websocket:Java-WebSocket:1.3.0'
3736
compile 'com.github.stfalcon:chatkit:0.2.1'
3837
compile 'com.squareup.picasso:picasso:2.5.2'
3938
compile 'com.google.firebase:firebase-core:10.2.1'
4039
compile 'com.google.firebase:firebase-crash:10.2.1'
4140
compile 'com.github.javiersantos:AppUpdater:2.6.1'
4241
compile 'com.android.support:appcompat-v7:25.3.1'
4342
compile 'com.google.firebase:firebase-messaging:10.2.1'
43+
compile 'com.android.support:customtabs:25.0.1'
4444
testCompile 'junit:junit:4.12'
4545
}
4646
apply plugin: 'com.google.gms.google-services'

app/src/main/java/eu/aero2x/andromedab/ContactSelect.java

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@
55
import android.content.Intent;
66
import android.content.SharedPreferences;
77
import android.net.Uri;
8+
import android.support.customtabs.CustomTabsIntent;
89
import android.support.design.widget.Snackbar;
910
import android.support.v7.app.AppCompatActivity;
1011
import android.os.Bundle;
1112
import android.text.InputType;
1213
import android.util.Log;
14+
import android.view.Menu;
15+
import android.view.MenuInflater;
16+
import android.view.MenuItem;
1317
import android.widget.EditText;
1418
import android.widget.ImageView;
1519
import android.widget.LinearLayout;
@@ -92,7 +96,7 @@ protected void onCreate(Bundle savedInstanceState) {
9296
AlertDialog.Builder builder = new AlertDialog.Builder(this);
9397
//you should edit this to fit your needs
9498
builder.setTitle("Andromeda Configuration");
95-
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");
99+
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...'");
96100

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

145149
builder.setNegativeButton("Exit", new DialogInterface.OnClickListener() {
146150
public void onClick(DialogInterface dialog, int whichButton) {
147-
finish();
151+
finishAffinity();
148152
}
149153
});
150154
builder.show();
@@ -154,7 +158,61 @@ public void onClick(DialogInterface dialog, int whichButton) {
154158
}
155159
}
156160

161+
@Override
162+
public boolean onCreateOptionsMenu(Menu menu) {
163+
MenuInflater inflater = getMenuInflater();
164+
inflater.inflate(R.menu.menu_conversations, menu);
165+
return true;
166+
}
157167

168+
@Override
169+
public boolean onOptionsItemSelected(MenuItem item) {
170+
// Handle item selection
171+
switch (item.getItemId()) {
172+
case R.id.resetConfig:
173+
AlertDialog alertDialog = new AlertDialog.Builder(ContactSelect.this).create();
174+
alertDialog.setTitle("Are you sure you want to reset the application?");
175+
alertDialog.setMessage("This will remove the entire application configuration and close the application.");
176+
alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, "Reset",
177+
new DialogInterface.OnClickListener() {
178+
public void onClick(DialogInterface dialog, int which) {
179+
Bundle bundle = new Bundle();
180+
bundle.putString(FirebaseAnalytics.Param.VALUE, "Erased settings");
181+
mFirebaseAnalytics.logEvent("app_menu_reset_settings", bundle);
182+
SharedPreferences.Editor editor = getSharedPreferences("CONFIG", MODE_PRIVATE).edit();
183+
//Nuke all preferences
184+
editor.putString("apiIPEndpoint",null);
185+
editor.putInt("apiPort",0);
186+
editor.putInt("socketPort",0);
187+
//Force safe instantly.
188+
editor.commit();
189+
//Close the activity
190+
finishAffinity();
191+
//Kill ourselves so that it's a completely clean state.
192+
System.exit(0);
193+
}
194+
});
195+
alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, "Cancel",
196+
new DialogInterface.OnClickListener() {
197+
public void onClick(DialogInterface dialog, int which) {
198+
Bundle bundle = new Bundle();
199+
bundle.putString(FirebaseAnalytics.Param.VALUE, "Erase settings canceled");
200+
mFirebaseAnalytics.logEvent("app_menu", bundle);
201+
dialog.dismiss();
202+
}
203+
});
204+
alertDialog.show();
205+
return true;
206+
case R.id.openProjectPage:
207+
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
208+
CustomTabsIntent customTabsIntent = builder.build();
209+
customTabsIntent.launchUrl(ContactSelect.this, Uri.parse("https://github.com/shusain93/Andromeda-iMessage"));
210+
211+
return true;
212+
default:
213+
return super.onOptionsItemSelected(item);
214+
}
215+
}
158216

159217
private void prepareView() {
160218
//Prepare our APP_CONSTANTS

app/src/main/java/eu/aero2x/andromedab/Conversation.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import android.content.ClipboardManager;
55
import android.content.Intent;
66
import android.net.Uri;
7+
import android.support.customtabs.CustomTabsIntent;
78
import android.support.design.widget.Snackbar;
89
import android.support.v7.app.AppCompatActivity;
910
import android.os.Bundle;
@@ -448,8 +449,9 @@ public void onMessageClick(CustomMessage message) {
448449
bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, "Tapped image to launch it in browser");
449450
mFirebaseAnalytics.logEvent("message_image_tap", bundle);
450451
//We have an image. They've tapped the image so we want to open it in the browser
451-
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(imageUrlIfExsists));
452-
startActivity(browserIntent);
452+
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
453+
CustomTabsIntent customTabsIntent = builder.build();
454+
customTabsIntent.launchUrl(Conversation.this, Uri.parse(imageUrlIfExsists));
453455
}
454456
}
455457
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<menu xmlns:android="http://schemas.android.com/apk/res/android">
3+
<item android:id="@+id/openProjectPage"
4+
android:title="Open project page"
5+
android:showAsAction="ifRoom"/>
6+
<item android:id="@+id/resetConfig"
7+
android:title="Reset configuration..."
8+
android:showAsAction="ifRoom"/>
9+
</menu>

0 commit comments

Comments
 (0)