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
6 changes: 4 additions & 2 deletions skunkworks_crow/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
<activity android:name=".views.ui.main.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Expand All @@ -45,7 +44,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 @@ -29,12 +29,15 @@

import org.odk.share.R;


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

public class SettingsActivity extends PreferenceActivity {



EditTextPreference hotspotNamePreference;
EditTextPreference bluetoothNamePreference;
Preference hotspotPasswordPreference;
Expand All @@ -48,11 +51,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 +87,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 +230,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 +251,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>
2 changes: 1 addition & 1 deletion skunkworks_crow/src/main/res/layout/toolbar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
app:contentInsetStart="@dimen/content_inset_start"
app:contentInsetStartWithNavigation="@dimen/content_inset_start_with_navigation"
app:titleTextColor="@android:color/white"
app:theme="@style/AppTheme.ActionBar" />
android:theme="@style/AppTheme.ActionBar" />
3 changes: 3 additions & 0 deletions skunkworks_crow/src/main/res/menu/main_menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@
android:id="@+id/menu_about"
android:title="@string/about"
app:showAsAction="never"/>
<item
android:title="Bug/Feedback"
/>
</menu>