diff --git a/README.md b/README.md index 0c4b08b0..ae3c06cb 100644 --- a/README.md +++ b/README.md @@ -29,14 +29,16 @@ It's "native" because it's developed in Java + the Android SDK (Android Studio). It's a WebApp because at this moment Diaspora doesn't have an API that can be used to create a native interface to retrieve the user's data, publications, direct messages and so on, that's why there are only WebApps for Diaspora out there. Why a WebApp is better than using the mobile site on a browser? Basically it provides better integration with the system (events coming into and going out of the app), notifications, customized interface and functions and a nice little icon that takes you directly to your favorite social network :) -### System Requirements +### Device Requirements The minimum version supported is Ice Cream Sandwitch, Android version 4.0.3 (or API 15) -### Permissions +### App Permissions It requires access to the Internet and to external storage to be able to upload photos when creating a new post and for taking screenshots. -## Project members: +## Main contributors + +**Project Lead:** gsantner () -- gsantner () - martinchodev () - scoute-dich () +- vanitasvitae () diff --git a/app/src/main/java/com/github/dfa/diaspora_android/activity/MainActivity.java b/app/src/main/java/com/github/dfa/diaspora_android/activity/MainActivity.java index 3c867324..3026ceda 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/activity/MainActivity.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/activity/MainActivity.java @@ -50,10 +50,15 @@ import android.text.Html; import android.text.SpannableString; import android.text.method.LinkMovementMethod; import android.text.util.Linkify; +import android.view.Gravity; +import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.View; +import android.view.WindowManager; +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodManager; import android.webkit.JavascriptInterface; import android.webkit.ValueCallback; import android.webkit.WebChromeClient; @@ -61,6 +66,7 @@ import android.webkit.WebSettings; import android.webkit.WebView; import android.widget.EditText; import android.widget.ImageView; +import android.widget.LinearLayout; import android.widget.ProgressBar; import android.widget.RadioButton; import android.widget.RadioGroup; @@ -530,41 +536,65 @@ public class MainActivity extends AppCompatActivity case R.id.action_search: { if (Helpers.isOnline(MainActivity.this)) { + final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); + LinearLayout layout = new LinearLayout(this); + layout.setOrientation(LinearLayout.VERTICAL); + layout.setGravity(Gravity.CENTER_HORIZONTAL); final EditText input = new EditText(this); - final AlertDialog.Builder dialog = new AlertDialog.Builder(this) - .setView(input) - .setIcon(R.drawable.ic_launcher) - .setTitle(R.string.search_alert_title) - .setPositiveButton(R.string.search_alert_people, new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int whichButton) { - String inputTag = input.getText().toString().trim(); - String cleanTag = inputTag.replaceAll("\\*", ""); - // this validate the input data for tagfind - if (cleanTag == null || cleanTag.equals("")) { - dialog.cancel(); // if user don�t have added a tag - Snackbar.make(swipeRefreshLayout, R.string.search_alert_bypeople_validate_needsomedata, Snackbar.LENGTH_LONG).show(); - } else { // User have added a search tag - webView.loadUrl("https://" + podDomain + "/people.mobile?q=" + cleanTag); - setTitle(R.string.search_by_person); - } + input.setSingleLine(true); + layout.setPadding(50, 0, 50, 0); + input.setHint(R.string.app_hashtag); + layout.addView(input); + + final DialogInterface.OnClickListener onSearchAccepted = new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + boolean wasClickedOnSearchForPeople = which == DialogInterface.BUTTON_NEGATIVE; + + String inputTag = input.getText().toString().trim(); + String cleanTag = inputTag.replaceAll(wasClickedOnSearchForPeople ? "\\*" : "\\#", ""); + // this validate the input data for tagfind + if (cleanTag == null || cleanTag.equals("")) { + Snackbar.make(swipeRefreshLayout, R.string.search_alert_bypeople_validate_needsomedata, Snackbar.LENGTH_LONG).show(); + } else { // User have added a search tag + if (wasClickedOnSearchForPeople) { + webView.loadUrl("https://" + podDomain + "/people.mobile?q=" + cleanTag); + setTitle(R.string.search_by_person); + } else { + webView.loadUrl("https://" + podDomain + "/tags/" + cleanTag); + setTitle(R.string.search_by_tag); } - }) - .setNegativeButton(R.string.search_alert_tag, - new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int whichButton) { - String inputTag = input.getText().toString().trim(); - String cleanTag = inputTag.replaceAll("\\#", ""); - // this validate the input data for tagfind - if (cleanTag == null || cleanTag.equals("")) { - dialog.cancel(); // if user hasn't added a tag - Snackbar.make(swipeRefreshLayout, R.string.search_alert_bytags_validate_needsomedata, Snackbar.LENGTH_LONG).show(); - } else { // User have added a search tag - webView.loadUrl("https://" + podDomain + "/tags/" + cleanTag); - setTitle(R.string.search_by_tag); - } - } - }); + } + + getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN); + imm.hideSoftInputFromWindow(input.getWindowToken(), 0); + } + }; + + final AlertDialog dialog = new AlertDialog.Builder(this) + .setView(layout) + .setTitle(R.string.search_alert_title) + .setCancelable(true) + .setPositiveButton(R.string.search_alert_tag, onSearchAccepted) + .setNegativeButton(R.string.search_alert_people, onSearchAccepted) + .create(); + + input.setOnEditorActionListener(new TextView.OnEditorActionListener() { + public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { + if (actionId == EditorInfo.IME_ACTION_DONE) { + dialog.hide(); + onSearchAccepted.onClick(null, 0); + return true; + } + return false; + } + }); + + // Popup keyboard dialog.show(); + input.requestFocus(); + getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); + imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); + } else { Snackbar.make(swipeRefreshLayout, R.string.no_internet, Snackbar.LENGTH_LONG).show(); } diff --git a/app/src/main/res/layout/main__content.xml b/app/src/main/res/layout/main__content.xml index 264d4bab..ed241c7a 100644 --- a/app/src/main/res/layout/main__content.xml +++ b/app/src/main/res/layout/main__content.xml @@ -27,8 +27,9 @@ diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 613c5222..ac6920ca 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -210,4 +210,5 @@ Saving image to https:// Share… + #DiasporaForAndroid