mirror of
https://github.com/gsantner/dandelion
synced 2024-11-22 12:22:08 +01:00
ProgressBar material, Improve search dialog
This commit is contained in:
parent
a3b10f090e
commit
d60069253e
4 changed files with 71 additions and 37 deletions
10
README.md
10
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.
|
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>)
|
||||||
|
|
|
@ -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() {
|
||||||
String inputTag = input.getText().toString().trim();
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
String cleanTag = inputTag.replaceAll("\\*", "");
|
boolean wasClickedOnSearchForPeople = which == DialogInterface.BUTTON_NEGATIVE;
|
||||||
// this validate the input data for tagfind
|
|
||||||
if (cleanTag == null || cleanTag.equals("")) {
|
String inputTag = input.getText().toString().trim();
|
||||||
dialog.cancel(); // if user don<EFBFBD>t have added a tag
|
String cleanTag = inputTag.replaceAll(wasClickedOnSearchForPeople ? "\\*" : "\\#", "");
|
||||||
Snackbar.make(swipeRefreshLayout, R.string.search_alert_bypeople_validate_needsomedata, Snackbar.LENGTH_LONG).show();
|
// this validate the input data for tagfind
|
||||||
} else { // User have added a search tag
|
if (cleanTag == null || cleanTag.equals("")) {
|
||||||
webView.loadUrl("https://" + podDomain + "/people.mobile?q=" + cleanTag);
|
Snackbar.make(swipeRefreshLayout, R.string.search_alert_bypeople_validate_needsomedata, Snackbar.LENGTH_LONG).show();
|
||||||
setTitle(R.string.search_by_person);
|
} 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() {
|
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
|
||||||
public void onClick(DialogInterface dialog, int whichButton) {
|
imm.hideSoftInputFromWindow(input.getWindowToken(), 0);
|
||||||
String inputTag = input.getText().toString().trim();
|
}
|
||||||
String cleanTag = inputTag.replaceAll("\\#", "");
|
};
|
||||||
// this validate the input data for tagfind
|
|
||||||
if (cleanTag == null || cleanTag.equals("")) {
|
final AlertDialog dialog = new AlertDialog.Builder(this)
|
||||||
dialog.cancel(); // if user hasn't added a tag
|
.setView(layout)
|
||||||
Snackbar.make(swipeRefreshLayout, R.string.search_alert_bytags_validate_needsomedata, Snackbar.LENGTH_LONG).show();
|
.setTitle(R.string.search_alert_title)
|
||||||
} else { // User have added a search tag
|
.setCancelable(true)
|
||||||
webView.loadUrl("https://" + podDomain + "/tags/" + cleanTag);
|
.setPositiveButton(R.string.search_alert_tag, onSearchAccepted)
|
||||||
setTitle(R.string.search_by_tag);
|
.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();
|
||||||
}
|
}
|
||||||
|
|
|
@ -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" />
|
||||||
|
|
|
@ -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>
|
||||||
|
|
Loading…
Reference in a new issue