Skip to content
This repository has been archived by the owner on Apr 9, 2021. It is now read-only.

Adding back button in settings activity and confirmation dialog in main activity #373

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.1'
classpath 'com.android.tools.build:gradle:3.6.1'
htg2704 marked this conversation as resolved.
Show resolved Hide resolved


// NOTE: Do not place your application dependencies here; they belong
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Oct 28 17:15:18 IST 2019
#Wed Mar 11 20:02:17 IST 2020
htg2704 marked this conversation as resolved.
Show resolved Hide resolved
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
htg2704 marked this conversation as resolved.
Show resolved Hide resolved
5 changes: 4 additions & 1 deletion skunkworks_crow/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@
android:value=".views.ui.main.MainActivity" />
</activity>
<activity android:name=".views.ui.instance.InstancesList" />
<activity android:name=".views.ui.settings.SettingsActivity" />
<activity android:name=".views.ui.settings.SettingsActivity"
android:parentActivityName=".views.ui.main.MainActivity">

</activity>
<activity android:name=".views.ui.about.WebViewActivity" />
<activity
android:name=".views.ui.about.AboutActivity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,16 @@ protected void onCreate(Bundle savedInstanceState) {
addListItemDivider();
}

@Override
public void onBackPressed(){
new AlertDialog.Builder(this).setIcon(R.drawable.ic_launcher_foreground).setTitle("Closing Skunkworks Crow").setMessage("Are you sure you want to close the app")
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
finish();
}
}).setNegativeButton("No",null).show();
}
private void setupAdapter() {
formAdapter = new FormsAdapter(this, null, this, instancesDao, transferDao);
recyclerView.setAdapter(formAdapter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.bluetooth.BluetoothAdapter;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
Expand All @@ -21,20 +22,25 @@
import android.view.WindowManager;
import android.widget.Toast;

import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.widget.Toolbar;

import com.google.android.material.textfield.TextInputEditText;
import com.google.android.material.textfield.TextInputLayout;

import org.odk.share.R;
import org.odk.share.views.ui.main.MainActivity;

/**
* Created by laksh on 5/27/2018.
*/

public class SettingsActivity extends PreferenceActivity {



EditTextPreference hotspotNamePreference;
EditTextPreference bluetoothNamePreference;
Preference hotspotPasswordPreference;
Expand All @@ -48,11 +54,20 @@ public class SettingsActivity extends PreferenceActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
ViewGroup root = getRootView();
Toolbar toolbar = (Toolbar) View.inflate(this, R.layout.toolbar, null);
toolbar.setTitle(getString(R.string.settings));
root.addView(toolbar, 0);
toolbar.setNavigationIcon(R.drawable.ic_back_navigation);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}

});

addPreferencesFromResource(R.xml.preferences_menu);
addPreferences();
Expand All @@ -75,6 +90,7 @@ private void addPreferences() {
btSecureModePreference = (CheckBoxPreference) findPreference(PreferenceKeys.KEY_BLUETOOTH_SECURE_MODE);
odkDestinationDirPreference = (EditTextPreference) findPreference(PreferenceKeys.KEY_ODK_DESTINATION_DIR);


prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());

defaultMethodPreference.setSummary(prefs.getString(PreferenceKeys.KEY_DEFAULT_TRANSFER_METHOD,
Expand Down Expand Up @@ -217,16 +233,16 @@ public void onShow(DialogInterface dialog) {
edtpass.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {

}

@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {

if (edtpass.getText().toString().length() >= 8) {
((AlertDialog) dialog) .getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true);
((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true);
} else {
((AlertDialog) dialog) .getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
}
}

Expand All @@ -238,12 +254,8 @@ public void afterTextChanged(Editable s) {
}
});


alertDialog.show();

alertDialog.setCancelable(true);
alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
}

}

}
15 changes: 15 additions & 0 deletions skunkworks_crow/src/main/res/drawable/ic_back_navigation.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">

<path
android:pathData="M20,11L7.8,11l5.6,-5.6L12,4l-8,8l8,8l1.4,-1.4L7.8,13L20,13L20,11z"
/>
<path
android:fillColor="#FFFFFF"
android:pathData="M20,11L7.8,11l5.6,-5.6L12,4l-8,8l8,8l1.4,-1.4L7.8,13L20,13L20,11z"
/>
</vector>