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 #369

Closed
wants to merge 6 commits into from
Closed
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
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'


// 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
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
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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert whatever changes you did in manifest file, as there is no need

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 @@ -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);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

avoid blank spaces

}

}
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>