mirror of
https://github.com/gsantner/dandelion
synced 2025-12-16 01:01:11 +01:00
Activity transitions, usability MainActivity, green accent color
This commit is contained in:
parent
a0d81da63d
commit
ff39986715
22 changed files with 255 additions and 226 deletions
|
|
@ -92,7 +92,7 @@ import java.text.SimpleDateFormat;
|
|||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
import butterknife.Bind;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
public class MainActivity extends AppCompatActivity
|
||||
|
|
@ -116,19 +116,19 @@ public class MainActivity extends AppCompatActivity
|
|||
private WebUserProfile webUserProfile;
|
||||
private final Handler uiHandler = new Handler();
|
||||
|
||||
@Bind(R.id.swipe)
|
||||
@BindView(R.id.swipe)
|
||||
SwipeRefreshLayout swipeRefreshLayout;
|
||||
|
||||
@Bind(R.id.progressBar)
|
||||
@BindView(R.id.progressBar)
|
||||
ProgressBar progressBar;
|
||||
|
||||
@Bind(R.id.toolbar)
|
||||
@BindView(R.id.toolbar)
|
||||
Toolbar toolbar;
|
||||
|
||||
@Bind(R.id.webView)
|
||||
@BindView(R.id.webView)
|
||||
ContextMenuWebView webView;
|
||||
|
||||
@Bind(R.id.fab_menubutton)
|
||||
@BindView(R.id.fab_menubutton)
|
||||
FloatingActionsMenu fab;
|
||||
|
||||
// NavHeader cannot be bound by Butterknife
|
||||
|
|
@ -238,7 +238,7 @@ public class MainActivity extends AppCompatActivity
|
|||
cookieManager.setCookie(url, cookies);
|
||||
cookieManager.setCookie("https://" + appSettings.getPodDomain(), cookies);
|
||||
for (String c : cookies.split(";")) {
|
||||
Log.d(App.TAG, "Cookie: " + c.split("=")[0] + " Value:" + c.split("=")[1]);
|
||||
//Log.d(App.TAG, "Cookie: " + c.split("=")[0] + " Value:" + c.split("=")[1]);
|
||||
}
|
||||
//new ProfileFetchTask(app).execute();
|
||||
}
|
||||
|
|
@ -361,7 +361,7 @@ public class MainActivity extends AppCompatActivity
|
|||
|
||||
View navHeader = navigationView.getHeaderView(0);
|
||||
navheaderTitle = ButterKnife.findById(navHeader, R.id.navheader_title);
|
||||
navheaderDescription = ButterKnife.findById(navHeader, R.id.navheader_description);
|
||||
navheaderDescription = ButterKnife.findById(navHeader, R.id.podselection__podupti_notice);
|
||||
navheaderImage = ButterKnife.findById(navHeader, R.id.navheader_user_image);
|
||||
|
||||
if (!appSettings.getName().equals("")) {
|
||||
|
|
@ -1013,9 +1013,9 @@ public class MainActivity extends AppCompatActivity
|
|||
}
|
||||
break;
|
||||
|
||||
case R.id.nav_settings_view: {
|
||||
case R.id.nav_settings_app: {
|
||||
final CharSequence[] options = {getString(R.string.settings_font), getString(R.string.settings_view), appSettings.isLoadImages() ?
|
||||
getString(R.string.settings_images_switch_off) : getString(R.string.settings_images_switch_on)};
|
||||
getString(R.string.settings_images_switch_off) : getString(R.string.settings_images_switch_on), getString(R.string.jb_pod)};
|
||||
|
||||
if (Helpers.isOnline(MainActivity.this)) {
|
||||
new AlertDialog.Builder(MainActivity.this)
|
||||
|
|
@ -1034,6 +1034,28 @@ public class MainActivity extends AppCompatActivity
|
|||
appSettings.setLoadImages(!appSettings.isLoadImages());
|
||||
webView.loadUrl(webView.getUrl());
|
||||
break;
|
||||
case 3:
|
||||
new AlertDialog.Builder(MainActivity.this)
|
||||
.setTitle(getString(R.string.confirmation))
|
||||
.setMessage(getString(R.string.change_pod_warning))
|
||||
.setPositiveButton(getString(R.string.yes),
|
||||
new DialogInterface.OnClickListener() {
|
||||
@TargetApi(11)
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
webView.clearCache(true);
|
||||
dialog.cancel();
|
||||
Intent i = new Intent(MainActivity.this, PodSelectionActivity.class);
|
||||
startActivity(i);
|
||||
finish();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(getString(R.string.no), new DialogInterface.OnClickListener() {
|
||||
@TargetApi(11)
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
dialog.cancel();
|
||||
}
|
||||
}).show();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}).show();
|
||||
|
|
@ -1045,7 +1067,7 @@ public class MainActivity extends AppCompatActivity
|
|||
|
||||
case R.id.nav_settings_diaspora: {
|
||||
final CharSequence[] options2 = {getString(R.string.jb_settings), getString(R.string.jb_manage_tags),
|
||||
getString(R.string.jb_contacts), getString(R.string.jb_pod)};
|
||||
getString(R.string.jb_contacts)};
|
||||
if (Helpers.isOnline(MainActivity.this)) {
|
||||
new AlertDialog.Builder(MainActivity.this)
|
||||
.setItems(options2, new DialogInterface.OnClickListener() {
|
||||
|
|
@ -1057,27 +1079,6 @@ public class MainActivity extends AppCompatActivity
|
|||
webView.loadUrl("https://" + podDomain + "/tag_followings/manage");
|
||||
if (options2[item].equals(getString(R.string.jb_contacts)))
|
||||
webView.loadUrl("https://" + podDomain + "/contacts");
|
||||
if (options2[item].equals(getString(R.string.jb_pod)))
|
||||
new AlertDialog.Builder(MainActivity.this)
|
||||
.setTitle(getString(R.string.confirmation))
|
||||
.setMessage(getString(R.string.change_pod_warning))
|
||||
.setPositiveButton(getString(R.string.yes),
|
||||
new DialogInterface.OnClickListener() {
|
||||
@TargetApi(11)
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
webView.clearCache(true);
|
||||
dialog.cancel();
|
||||
Intent i = new Intent(MainActivity.this, PodsActivity.class);
|
||||
startActivity(i);
|
||||
finish();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(getString(R.string.no), new DialogInterface.OnClickListener() {
|
||||
@TargetApi(11)
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
dialog.cancel();
|
||||
}
|
||||
}).show();
|
||||
}
|
||||
}).show();
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ package com.github.dfa.diaspora_android.activity;
|
|||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
|
|
@ -32,7 +31,9 @@ import android.os.Bundle;
|
|||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.text.Editable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.TextWatcher;
|
||||
import android.text.util.Linkify;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
|
@ -40,7 +41,6 @@ import android.webkit.CookieManager;
|
|||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
|
@ -52,36 +52,32 @@ import com.github.dfa.diaspora_android.util.Helpers;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
|
||||
public class PodsActivity extends AppCompatActivity {
|
||||
|
||||
public class PodSelectionActivity extends AppCompatActivity {
|
||||
private BroadcastReceiver podListReceiver;
|
||||
private EditText filter;
|
||||
private ListView lv;
|
||||
private ProgressDialog progressDialog;
|
||||
private App app;
|
||||
|
||||
@BindView(R.id.podselection__edit_filter)
|
||||
public EditText filter;
|
||||
|
||||
@BindView(R.id.podselection__listpods)
|
||||
public ListView lv;
|
||||
|
||||
private String podSelected = "";
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_pods);
|
||||
setContentView(R.layout.podselection_activity);
|
||||
ButterKnife.bind(this);
|
||||
app = (App) getApplication();
|
||||
|
||||
filter = (EditText) findViewById(R.id.edtFilter);
|
||||
lv = (ListView) findViewById(R.id.lstPods);
|
||||
lv.setTextFilterEnabled(true);
|
||||
|
||||
ImageView imgSelectPod = (ImageView) findViewById(R.id.imgSelectPod);
|
||||
imgSelectPod.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (filter.getText().length() > 4 && filter.getText().toString().contains(""))
|
||||
askConfirmation(filter.getText().toString());
|
||||
else
|
||||
Snackbar.make(lv, R.string.valid_pod, Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
|
||||
podListReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
|
|
@ -89,9 +85,6 @@ public class PodsActivity extends AppCompatActivity {
|
|||
Bundle extras = intent.getExtras();
|
||||
String[] pods = extras.getStringArray("pods");
|
||||
|
||||
if (progressDialog != null)
|
||||
progressDialog.dismiss();
|
||||
|
||||
if (pods != null && pods.length > 0)
|
||||
updateListview(pods);
|
||||
else {
|
||||
|
|
@ -103,37 +96,38 @@ public class PodsActivity extends AppCompatActivity {
|
|||
|
||||
registerReceiver(podListReceiver, new IntentFilter(GetPodsService.MESSAGE));
|
||||
|
||||
progressDialog = new ProgressDialog(PodsActivity.this);
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.setIndeterminate(true);
|
||||
progressDialog.setMessage(getString(R.string.loading_podlist));
|
||||
|
||||
if (Helpers.isOnline(PodsActivity.this)) {
|
||||
progressDialog.show();
|
||||
} else {
|
||||
if (!Helpers.isOnline(PodSelectionActivity.this)) {
|
||||
Snackbar.make(lv, R.string.no_internet, Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
||||
@OnClick(R.id.podselection__button_select_pod)
|
||||
public void onButtonSelectPodClicked(View view) {
|
||||
if (filter.getText().length() > 4 && filter.getText().toString().contains("")) {
|
||||
askConfirmation(filter.getText().toString());
|
||||
} else {
|
||||
Snackbar.make(lv, R.string.valid_pod, Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
Intent i = new Intent(PodsActivity.this, GetPodsService.class);
|
||||
Intent i = new Intent(PodSelectionActivity.this, GetPodsService.class);
|
||||
startService(i);
|
||||
}
|
||||
|
||||
|
||||
private void updateListview(String[] source) {
|
||||
private void updateListview(String[] allPods) {
|
||||
final ArrayList<String> podList = new ArrayList<>();
|
||||
|
||||
for (String aSource : source) {
|
||||
podList.add(aSource.toLowerCase());
|
||||
for (String pod : allPods) {
|
||||
podList.add(pod.toLowerCase());
|
||||
}
|
||||
Collections.sort(podList);
|
||||
//Collections.sort(podList);
|
||||
|
||||
final ArrayAdapter<String> adapter = new ArrayAdapter<>(
|
||||
PodsActivity.this,
|
||||
PodSelectionActivity.this,
|
||||
android.R.layout.simple_list_item_1,
|
||||
podList);
|
||||
lv.setAdapter(adapter);
|
||||
|
|
@ -150,55 +144,36 @@ public class PodsActivity extends AppCompatActivity {
|
|||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
(adapter).getFilter().filter(s.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void askConfirmation(final String podDomain) {
|
||||
if (Helpers.isOnline(PodsActivity.this)) {
|
||||
new AlertDialog.Builder(PodsActivity.this)
|
||||
podSelected = podDomain;
|
||||
|
||||
// Make link clickable
|
||||
final SpannableString dialogMessage = new SpannableString(getString(R.string.confirm_pod, podDomain));
|
||||
Linkify.addLinks(dialogMessage, Linkify.ALL);
|
||||
|
||||
if (Helpers.isOnline(PodSelectionActivity.this)) {
|
||||
new AlertDialog.Builder(PodSelectionActivity.this)
|
||||
.setTitle(getString(R.string.confirmation))
|
||||
.setMessage(getString(R.string.confirm_pod) + podDomain + "?")
|
||||
.setMessage(dialogMessage)
|
||||
.setPositiveButton(R.string.yes,
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
|
||||
app.getSettings().setPodDomain(podDomain);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
try {
|
||||
CookieManager.getInstance().removeAllCookies(null);
|
||||
CookieManager.getInstance().removeSessionCookies(null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
CookieManager.getInstance().removeAllCookie();
|
||||
CookieManager.getInstance().removeSessionCookie();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
Intent i = new Intent(PodsActivity.this, MainActivity.class);
|
||||
dialog.cancel();
|
||||
startActivity(i);
|
||||
finish();
|
||||
onPodSelectionConfirmed();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
|
||||
@TargetApi(11)
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
dialog.cancel();
|
||||
podSelected = "";
|
||||
}
|
||||
}).show();
|
||||
|
||||
|
|
@ -207,18 +182,41 @@ public class PodsActivity extends AppCompatActivity {
|
|||
}
|
||||
}
|
||||
|
||||
public void onPodSelectionConfirmed(){
|
||||
app.getSettings().setPodDomain(podSelected);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
try {
|
||||
CookieManager.getInstance().removeAllCookies(null);
|
||||
CookieManager.getInstance().removeSessionCookies(null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
CookieManager.getInstance().removeAllCookie();
|
||||
CookieManager.getInstance().removeSessionCookie();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
Intent intent = new Intent(PodSelectionActivity.this, MainActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
||||
startActivity(intent);
|
||||
overridePendingTransition(R.anim.fadein, R.anim.fadeout);
|
||||
finish();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
Snackbar snackbar = Snackbar
|
||||
.make(lv, R.string.confirm_exit, Snackbar.LENGTH_LONG)
|
||||
Snackbar.make(lv, R.string.confirm_exit, Snackbar.LENGTH_LONG)
|
||||
.setAction(R.string.yes, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
moveTaskToBack(true);
|
||||
}
|
||||
});
|
||||
snackbar.show();
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -235,20 +233,18 @@ public class PodsActivity extends AppCompatActivity {
|
|||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
int id = item.getItemId();
|
||||
|
||||
if (id == R.id.action_reload) {
|
||||
if (Helpers.isOnline(PodsActivity.this)) {
|
||||
progressDialog.show();
|
||||
Intent i = new Intent(PodsActivity.this, GetPodsService.class);
|
||||
startService(i);
|
||||
return true;
|
||||
} else {
|
||||
Snackbar.make(lv, R.string.no_internet, Snackbar.LENGTH_LONG).show();
|
||||
return false;
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_reload: {
|
||||
if (Helpers.isOnline(PodSelectionActivity.this)) {
|
||||
Intent i = new Intent(PodSelectionActivity.this, GetPodsService.class);
|
||||
startService(i);
|
||||
return true;
|
||||
} else {
|
||||
Snackbar.make(lv, R.string.no_internet, Snackbar.LENGTH_LONG).show();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
|
|
@ -22,6 +22,7 @@ package com.github.dfa.diaspora_android.activity;
|
|||
import android.content.Intent;
|
||||
import android.content.res.TypedArray;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageView;
|
||||
|
|
@ -39,33 +40,34 @@ public class SplashActivity extends AppCompatActivity {
|
|||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setContentView(R.layout.activity_splash);
|
||||
setContentView(R.layout.splash_activity);
|
||||
app = (App) getApplication();
|
||||
|
||||
ImageView imgSplash = (ImageView) findViewById(R.id.imgSplash);
|
||||
ImageView imgSplash = (ImageView) findViewById(R.id.splash__splashimage);
|
||||
|
||||
TypedArray images = getResources().obtainTypedArray(R.array.splash_images);
|
||||
int choice = (int) (Math.random() * images.length());
|
||||
imgSplash.setImageResource(images.getResourceId(choice, R.drawable.splashscreen1));
|
||||
images.recycle();
|
||||
|
||||
|
||||
Timer timer = new Timer();
|
||||
timer.schedule(new TimerTask() {
|
||||
int delay = getResources().getInteger(R.integer.splash_delay);
|
||||
Handler handler = new Handler();
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Intent i;
|
||||
|
||||
Intent intent;
|
||||
if (!app.getSettings().getPodDomain().equals("")) {
|
||||
i = new Intent(SplashActivity.this, MainActivity.class);
|
||||
intent = new Intent(SplashActivity.this, MainActivity.class);
|
||||
} else {
|
||||
i = new Intent(SplashActivity.this, PodsActivity.class);
|
||||
intent = new Intent(SplashActivity.this, PodSelectionActivity.class);
|
||||
}
|
||||
startActivity(i);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
||||
startActivity(intent);
|
||||
overridePendingTransition(R.anim.fadein, R.anim.fadeout);
|
||||
finish();
|
||||
}
|
||||
}, 2000);
|
||||
}, delay);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -97,15 +97,13 @@ public class GetPodsService extends Service {
|
|||
}
|
||||
//Parse the JSON Data
|
||||
try {
|
||||
JSONObject j = new JSONObject(builder.toString());
|
||||
JSONArray jr = j.getJSONArray("pods");
|
||||
Log.d(TAG, "Number of entries " + jr.length());
|
||||
JSONObject jsonObjectAll = new JSONObject(builder.toString());
|
||||
JSONArray jsonArrayAll = jsonObjectAll.getJSONArray("pods");
|
||||
Log.d(TAG, "Number of entries " + jsonArrayAll.length());
|
||||
list = new ArrayList<>();
|
||||
for (int i = 0; i < jr.length(); i++) {
|
||||
JSONObject jo = jr.getJSONObject(i);
|
||||
Log.d(TAG, jo.getString("domain"));
|
||||
String secure = jo.getString("secure");
|
||||
if (secure.equals("true"))
|
||||
for (int i = 0; i < jsonArrayAll.length(); i++) {
|
||||
JSONObject jo = jsonArrayAll.getJSONObject(i);
|
||||
if (jo.getString("secure").equals("true"))
|
||||
list.add(jo.getString("domain"));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ package com.github.dfa.diaspora_android.util;
|
|||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.webkit.WebView;
|
||||
|
||||
public class Helpers {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue