mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-15 04:18:53 +01:00
@@ -2,11 +2,13 @@ package org.briarproject.android;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
|
||||
import org.briarproject.android.BriarService.BriarBinder;
|
||||
import org.briarproject.android.BriarService.BriarServiceConnection;
|
||||
import org.briarproject.android.panic.ExitActivity;
|
||||
import org.briarproject.api.db.DatabaseConfig;
|
||||
import org.briarproject.api.db.DatabaseExecutor;
|
||||
import org.briarproject.api.lifecycle.LifecycleManager;
|
||||
@@ -78,7 +80,7 @@ public class BriarActivity extends BaseActivity {
|
||||
if (bound) unbindService(serviceConnection);
|
||||
}
|
||||
|
||||
protected void signOut() {
|
||||
protected void signOut(final boolean removeFromRecentApps) {
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -95,15 +97,28 @@ public class BriarActivity extends BaseActivity {
|
||||
LOG.warning("Interrupted while waiting for service");
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
finishAndExit();
|
||||
|
||||
if(removeFromRecentApps){
|
||||
ExitActivity.exitAndRemoveFromRecentApps(BriarActivity.this);
|
||||
} else {
|
||||
finishAndExit();
|
||||
}
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
|
||||
protected void signOut() {
|
||||
signOut(false);
|
||||
}
|
||||
|
||||
private void finishAndExit() {
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
finish();
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
finishAndRemoveTask();
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
LOG.info("Exiting");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.panic.PanicPreferencesActivity;
|
||||
import org.briarproject.android.util.FixedVerticalSpace;
|
||||
import org.briarproject.android.util.HorizontalBorder;
|
||||
import org.briarproject.android.util.LayoutUtils;
|
||||
@@ -68,6 +69,7 @@ OnClickListener {
|
||||
private CheckBox notifyPrivateMessages = null, notifyForumPosts = null;
|
||||
private CheckBox notifyVibration = null;
|
||||
private TextView torOverWifi = null, torOverWifiHint = null;
|
||||
private TextView panicSettings = null, panicSettingsHint = null;
|
||||
private TextView notifySound = null, notifySoundHint = null;
|
||||
private ListLoadingProgressBar progress = null;
|
||||
private ImageButton testingButton = null;
|
||||
@@ -141,6 +143,30 @@ OnClickListener {
|
||||
torOverWifiHint.setOnClickListener(this);
|
||||
settings.addView(torOverWifiHint);
|
||||
|
||||
TextView panicTitle = new TextView(this);
|
||||
panicTitle.setPadding(pad, 0, pad, 0);
|
||||
panicTitle.setTypeface(DEFAULT_BOLD);
|
||||
panicTitle.setTextColor(titleText);
|
||||
panicTitle.setText(R.string.panic_setting_title);
|
||||
settings.addView(panicTitle);
|
||||
|
||||
underline = new HorizontalBorder(this);
|
||||
underline.setBackgroundColor(titleUnderline);
|
||||
settings.addView(underline);
|
||||
|
||||
panicSettings = new TextView(this);
|
||||
panicSettings.setPadding(pad, pad, pad, 0);
|
||||
panicSettings.setTextSize(18);
|
||||
panicSettings.setText(R.string.panic_setting);
|
||||
panicSettings.setOnClickListener(this);
|
||||
settings.addView(panicSettings);
|
||||
|
||||
panicSettingsHint = new TextView(this);
|
||||
panicSettingsHint.setText(R.string.panic_setting_hint);
|
||||
panicSettingsHint.setPadding(pad, 0, pad, pad);
|
||||
panicSettingsHint.setOnClickListener(this);
|
||||
settings.addView(panicSettingsHint);
|
||||
|
||||
TextView notificationsTitle = new TextView(this);
|
||||
notificationsTitle.setPadding(pad, 0, pad, 0);
|
||||
notificationsTitle.setTypeface(DEFAULT_BOLD);
|
||||
@@ -317,6 +343,8 @@ OnClickListener {
|
||||
s.putBoolean("notifyPrivateMessages",
|
||||
notifyPrivateMessages.isChecked());
|
||||
storeSettings(s);
|
||||
} else if (view == panicSettings || view == panicSettingsHint) {
|
||||
startActivity(new Intent(this, PanicPreferencesActivity.class));
|
||||
} else if (view == notifyForumPosts) {
|
||||
Settings s = new Settings();
|
||||
s.putBoolean("notifyForumPosts", notifyForumPosts.isChecked());
|
||||
|
||||
@@ -7,6 +7,7 @@ import android.os.Bundle;
|
||||
import android.os.StrictMode;
|
||||
import android.os.StrictMode.ThreadPolicy;
|
||||
import android.os.StrictMode.VmPolicy;
|
||||
import android.support.v7.preference.PreferenceManager;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
@@ -64,6 +65,9 @@ public class SplashScreenActivity extends RoboSplashActivity {
|
||||
logo.setImageResource(R.drawable.briar_logo_large);
|
||||
layout.addView(logo);
|
||||
|
||||
PreferenceManager
|
||||
.setDefaultValues(this, R.xml.panic_preferences, false);
|
||||
|
||||
setContentView(layout);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package org.briarproject.android.panic;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
|
||||
import org.briarproject.android.BaseActivity;
|
||||
|
||||
public class ExitActivity extends BaseActivity {
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
finishAndRemoveTask();
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
public static void exitAndRemoveFromRecentApps(final BaseActivity activity) {
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Intent intent = new Intent(activity, ExitActivity.class);
|
||||
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
| Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
|
||||
| Intent.FLAG_ACTIVITY_CLEAR_TASK
|
||||
| Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
||||
|
||||
activity.startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package org.briarproject.android.panic;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.BriarActivity;
|
||||
|
||||
public class PanicPreferencesActivity extends BriarActivity {
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
if (actionBar != null) {
|
||||
actionBar.setHomeButtonEnabled(true);
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
|
||||
setContentView(R.layout.activity_panic_preferences);
|
||||
}
|
||||
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == android.R.id.home) {
|
||||
onBackPressed();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package org.briarproject.android.panic;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.preference.PreferenceFragmentCompat;
|
||||
|
||||
import org.briarproject.R;
|
||||
|
||||
public class PanicPreferencesFragment extends PreferenceFragmentCompat {
|
||||
|
||||
@Override
|
||||
public void onCreatePreferences(Bundle bundle, String s) {
|
||||
addPreferencesFromResource(R.xml.panic_preferences);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package org.briarproject.android.panic;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.preference.PreferenceManager;
|
||||
|
||||
import org.briarproject.android.BriarActivity;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class PanicResponderActivity extends BriarActivity {
|
||||
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(PanicResponderActivity.class.getName());
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
SharedPreferences sharedPref = PreferenceManager
|
||||
.getDefaultSharedPreferences(this);
|
||||
|
||||
Intent intent = getIntent();
|
||||
if (intent != null && sharedPref.getBoolean("pref_key_lock", true)) {
|
||||
LOG.info("Signing out...");
|
||||
signOut(true);
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
finishAndRemoveTask();
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user