1
0
Fork 0
mirror of https://github.com/gsantner/dandelion synced 2024-11-25 22:02:08 +01:00

ProgressBar material, Improve search dialog

This commit is contained in:
Gregor Santner 2016-06-04 19:44:38 +02:00
parent a3b10f090e
commit d60069253e
4 changed files with 71 additions and 37 deletions

View file

@ -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. 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 :) 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) 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. 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 (<https://gsantner.github.io>)
- gsantner (<https://gsantner.github.io>)
- martinchodev (<https://github.com/martinchodev>) - martinchodev (<https://github.com/martinchodev>)
- scoute-dich (<https://github.com/scoute-dich>) - scoute-dich (<https://github.com/scoute-dich>)
- vanitasvitae (<https://github.com/vanitasvitae>)

View file

@ -50,10 +50,15 @@ import android.text.Html;
import android.text.SpannableString; import android.text.SpannableString;
import android.text.method.LinkMovementMethod; import android.text.method.LinkMovementMethod;
import android.text.util.Linkify; import android.text.util.Linkify;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; 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.JavascriptInterface;
import android.webkit.ValueCallback; import android.webkit.ValueCallback;
import android.webkit.WebChromeClient; import android.webkit.WebChromeClient;
@ -61,6 +66,7 @@ import android.webkit.WebSettings;
import android.webkit.WebView; import android.webkit.WebView;
import android.widget.EditText; import android.widget.EditText;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.RadioButton; import android.widget.RadioButton;
import android.widget.RadioGroup; import android.widget.RadioGroup;
@ -530,41 +536,65 @@ public class MainActivity extends AppCompatActivity
case R.id.action_search: { case R.id.action_search: {
if (Helpers.isOnline(MainActivity.this)) { 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 EditText input = new EditText(this);
final AlertDialog.Builder dialog = new AlertDialog.Builder(this) input.setSingleLine(true);
.setView(input) layout.setPadding(50, 0, 50, 0);
.setIcon(R.drawable.ic_launcher) input.setHint(R.string.app_hashtag);
.setTitle(R.string.search_alert_title) layout.addView(input);
.setPositiveButton(R.string.search_alert_people, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) { 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 inputTag = input.getText().toString().trim();
String cleanTag = inputTag.replaceAll("\\*", ""); String cleanTag = inputTag.replaceAll(wasClickedOnSearchForPeople ? "\\*" : "\\#", "");
// this validate the input data for tagfind // this validate the input data for tagfind
if (cleanTag == null || cleanTag.equals("")) { if (cleanTag == null || cleanTag.equals("")) {
dialog.cancel(); // if user don<EFBFBD>t have added a tag
Snackbar.make(swipeRefreshLayout, R.string.search_alert_bypeople_validate_needsomedata, Snackbar.LENGTH_LONG).show(); Snackbar.make(swipeRefreshLayout, R.string.search_alert_bypeople_validate_needsomedata, Snackbar.LENGTH_LONG).show();
} else { // User have added a search tag } else { // User have added a search tag
if (wasClickedOnSearchForPeople) {
webView.loadUrl("https://" + podDomain + "/people.mobile?q=" + cleanTag); webView.loadUrl("https://" + podDomain + "/people.mobile?q=" + cleanTag);
setTitle(R.string.search_by_person); setTitle(R.string.search_by_person);
} } else {
}
})
.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); webView.loadUrl("https://" + podDomain + "/tags/" + cleanTag);
setTitle(R.string.search_by_tag); 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(); dialog.show();
input.requestFocus();
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
} else { } else {
Snackbar.make(swipeRefreshLayout, R.string.no_internet, Snackbar.LENGTH_LONG).show(); Snackbar.make(swipeRefreshLayout, R.string.no_internet, Snackbar.LENGTH_LONG).show();
} }

View file

@ -27,8 +27,9 @@
<ProgressBar <ProgressBar
android:id="@+id/progressBar" android:id="@+id/progressBar"
style="@android:style/Widget.ProgressBar.Horizontal" style="@style/Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:indeterminate="false"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:maxHeight="4dip" android:maxHeight="4dip"
android:minHeight="4dip" /> android:minHeight="4dip" />

View file

@ -210,4 +210,5 @@
<string name="toast_saved_image_to_location">Saving image to</string> <string name="toast_saved_image_to_location">Saving image to</string>
<string name="prefix_https" translatable="false">https://</string> <string name="prefix_https" translatable="false">https://</string>
<string name="share_dotdodot">Share…</string> <string name="share_dotdodot">Share…</string>
<string name="app_hashtag" translatable="false">#DiasporaForAndroid</string>
</resources> </resources>