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

Removed unused classes and cleaned code up

This commit is contained in:
vanitasvitae 2016-08-23 21:23:36 +02:00
parent 7091b1ba31
commit f8d8126c0e
15 changed files with 44 additions and 64 deletions

View file

@ -107,7 +107,7 @@ public class MainActivity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener, WebUserProfileChangedListener { implements NavigationView.OnNavigationItemSelectedListener, WebUserProfileChangedListener {
static final int INPUT_FILE_REQUEST_CODE = 1; private static final int INPUT_FILE_REQUEST_CODE = 1;
private static final int REQUEST_CODE_ASK_PERMISSIONS = 123; private static final int REQUEST_CODE_ASK_PERMISSIONS = 123;
public static final int REQUEST_CODE_ASK_PERMISSIONS_SAVE_IMAGE = 124; public static final int REQUEST_CODE_ASK_PERMISSIONS_SAVE_IMAGE = 124;
@ -120,7 +120,6 @@ public class MainActivity extends AppCompatActivity
public static final String EXTRA_URL = "com.github.dfa.diaspora_android.extra_url"; public static final String EXTRA_URL = "com.github.dfa.diaspora_android.extra_url";
private App app; private App app;
private String podDomain;
private ValueCallback<Uri[]> mFilePathCallback; private ValueCallback<Uri[]> mFilePathCallback;
private String mCameraPhotoPath; private String mCameraPhotoPath;
private WebSettings webSettings; private WebSettings webSettings;
@ -132,7 +131,7 @@ public class MainActivity extends AppCompatActivity
private Snackbar snackbarExitApp; private Snackbar snackbarExitApp;
private Snackbar snackbarNewNotification; private Snackbar snackbarNewNotification;
private Snackbar snackbarNoInternet; private Snackbar snackbarNoInternet;
public String textToBeShared = null; private String textToBeShared = null;
/** /**
* UI Bindings * UI Bindings
@ -233,7 +232,6 @@ public class MainActivity extends AppCompatActivity
setupNavigationSlider(); setupNavigationSlider();
progressBar = (ProgressBar) findViewById(R.id.progressBar); progressBar = (ProgressBar) findViewById(R.id.progressBar);
podDomain = appSettings.getPodDomain();
String url = urls.getPodUrl(); String url = urls.getPodUrl();
if (savedInstanceState == null) { if (savedInstanceState == null) {
@ -864,7 +862,7 @@ public class MainActivity extends AppCompatActivity
app.getAvatarImageLoader().startImageDownload(navheaderImage, avatarUrl); app.getAvatarImageLoader().startImageDownload(navheaderImage, avatarUrl);
} }
void handleSendText(Intent intent) { private void handleSendText(Intent intent) {
String content = WebHelper.replaceUrlWithMarkdown(intent.getStringExtra(Intent.EXTRA_TEXT)); String content = WebHelper.replaceUrlWithMarkdown(intent.getStringExtra(Intent.EXTRA_TEXT));
if (appSettings.isAppendSharedViaApp()) { if (appSettings.isAppendSharedViaApp()) {
// &#10; = \n // &#10; = \n
@ -883,9 +881,9 @@ public class MainActivity extends AppCompatActivity
/** /**
* Handle sent text + subject * Handle sent text + subject
* *
* @param intent * @param intent intent
*/ */
void handleSendSubject(Intent intent) { private void handleSendSubject(Intent intent) {
webView.loadUrlNew(urls.getNewPostUrl()); webView.loadUrlNew(urls.getNewPostUrl());
String content = WebHelper.replaceUrlWithMarkdown(intent.getStringExtra(Intent.EXTRA_TEXT)); String content = WebHelper.replaceUrlWithMarkdown(intent.getStringExtra(Intent.EXTRA_TEXT));
String subject = WebHelper.replaceUrlWithMarkdown(intent.getStringExtra(Intent.EXTRA_SUBJECT)); String subject = WebHelper.replaceUrlWithMarkdown(intent.getStringExtra(Intent.EXTRA_SUBJECT));
@ -905,9 +903,9 @@ public class MainActivity extends AppCompatActivity
//TODO: Implement? //TODO: Implement?
private void handleSendImage(Intent intent) { private void handleSendImage(Intent intent) {
final Uri imageUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM); final Uri imageUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
if (imageUri != null) { if (imageUri != null) {
// Update UI to reflect text being shared // TODO: Update UI to reflect text being shared
} }
Toast.makeText(this, "Not yet implemented.", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "Not yet implemented.", Toast.LENGTH_SHORT).show();
} }
@ -948,11 +946,6 @@ public class MainActivity extends AppCompatActivity
public void contentHasBeenShared() { public void contentHasBeenShared() {
textToBeShared = null; textToBeShared = null;
} }
@JavascriptInterface
public void log(final String log) {
//Log.d(App.TAG, "[wv] " + log);
}
} }
@SuppressWarnings("StatementWithEmptyBody") @SuppressWarnings("StatementWithEmptyBody")
@ -1062,6 +1055,7 @@ public class MainActivity extends AppCompatActivity
@Override @Override
public void onClick(DialogInterface dialog, int item) { public void onClick(DialogInterface dialog, int item) {
if (options[item].equals(getString(R.string.help_license__name))) { if (options[item].equals(getString(R.string.help_license__name))) {
final SpannableString s = new SpannableString(Html.fromHtml(getString(R.string.help_license__content))); final SpannableString s = new SpannableString(Html.fromHtml(getString(R.string.help_license__content)));
Linkify.addLinks(s, Linkify.WEB_URLS); Linkify.addLinks(s, Linkify.WEB_URLS);
final AlertDialog d = new AlertDialog.Builder(MainActivity.this) final AlertDialog d = new AlertDialog.Builder(MainActivity.this)

View file

@ -60,13 +60,13 @@ public class PodSelectionActivity extends AppCompatActivity {
private App app; private App app;
@BindView(R.id.podselection__edit_filter) @BindView(R.id.podselection__edit_filter)
public EditText editFilter; EditText editFilter;
@BindView(R.id.podselection__listpods) @BindView(R.id.podselection__listpods)
public ListView listPods; ListView listPods;
@BindView(R.id.toolbar) @BindView(R.id.toolbar)
public Toolbar toolbar; Toolbar toolbar;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -184,22 +184,21 @@ public class PodSelectionActivity extends AppCompatActivity {
.show(); .show();
} }
public void onPodSelectionConfirmed(String selectedPod) { private void onPodSelectionConfirmed(String selectedPod) {
app.getSettings().setPodDomain(selectedPod); app.getSettings().setPodDomain(selectedPod);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
try { try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
CookieManager.getInstance().removeAllCookies(null); CookieManager.getInstance().removeAllCookies(null);
CookieManager.getInstance().removeSessionCookies(null); CookieManager.getInstance().removeSessionCookies(null);
} catch (Exception e) { } else {
e.printStackTrace(); //noinspection deprecation
}
} else {
try {
CookieManager.getInstance().removeAllCookie(); CookieManager.getInstance().removeAllCookie();
//noinspection deprecation
CookieManager.getInstance().removeSessionCookie(); CookieManager.getInstance().removeSessionCookie();
} catch (Exception e) {
e.printStackTrace();
} }
} catch (Exception e) {
e.printStackTrace();
} }
Helpers.animateToActivity(this, MainActivity.class, true); Helpers.animateToActivity(this, MainActivity.class, true);

View file

@ -45,8 +45,8 @@ public class SettingsActivity extends PreferenceActivity {
getFragmentManager().beginTransaction().replace(android.R.id.content, new SettingsFragment()).commit(); getFragmentManager().beginTransaction().replace(android.R.id.content, new SettingsFragment()).commit();
} }
public void setActivityRestartRequired(boolean b) { private void setActivityRestartRequired() {
this.activityRestartRequired = b; this.activityRestartRequired = true;
} }
public static class SettingsFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener { public static class SettingsFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
@ -84,7 +84,7 @@ public class SettingsActivity extends PreferenceActivity {
key.equals(getString(R.string.pref_key__proxy_host)) || key.equals(getString(R.string.pref_key__proxy_host)) ||
key.equals(getString(R.string.pref_key__proxy_port)) || key.equals(getString(R.string.pref_key__proxy_port)) ||
key.startsWith("pref_key__visibility_nav__"))) { key.startsWith("pref_key__visibility_nav__"))) {
((SettingsActivity) getActivity()).setActivityRestartRequired(true); ((SettingsActivity) getActivity()).setActivityRestartRequired();
} }
} }

View file

@ -28,7 +28,6 @@ import android.widget.ImageView;
import com.github.dfa.diaspora_android.App; import com.github.dfa.diaspora_android.App;
import com.github.dfa.diaspora_android.R; import com.github.dfa.diaspora_android.R;
import com.github.dfa.diaspora_android.util.Helpers; import com.github.dfa.diaspora_android.util.Helpers;
import com.github.dfa.diaspora_android.util.WebHelper;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
@ -38,7 +37,7 @@ public class SplashActivity extends AppCompatActivity {
private App app; private App app;
@BindView(R.id.splash__splashimage) @BindView(R.id.splash__splashimage)
public ImageView imgSplash; ImageView imgSplash;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -56,7 +55,7 @@ public class SplashActivity extends AppCompatActivity {
new Handler().postDelayed(startActivityRunnable, delay); new Handler().postDelayed(startActivityRunnable, delay);
} }
final Runnable startActivityRunnable = new Runnable() { private final Runnable startActivityRunnable = new Runnable() {
public void run() { public void run() {
boolean hasPodDomain = app.getSettings().hasPodDomain(); boolean hasPodDomain = app.getSettings().hasPodDomain();
Helpers.animateToActivity(SplashActivity.this, Helpers.animateToActivity(SplashActivity.this,

View file

@ -25,6 +25,7 @@ import android.content.SharedPreferences;
import com.github.dfa.diaspora_android.R; import com.github.dfa.diaspora_android.R;
/** /**
* Settings
* Created by gsantner (https://gsantner.github.io/) on 20.03.16. Part of Diaspora for Android. * Created by gsantner (https://gsantner.github.io/) on 20.03.16. Part of Diaspora for Android.
*/ */
public class AppSettings { public class AppSettings {
@ -63,7 +64,7 @@ public class AppSettings {
} }
private void setStringArray(SharedPreferences pref, int keyRessourceId, Object[] values) { private void setStringArray(SharedPreferences pref, int keyRessourceId, Object[] values) {
StringBuffer sb = new StringBuffer(); StringBuilder sb = new StringBuilder();
for (Object value : values) { for (Object value : values) {
sb.append("%%%"); sb.append("%%%");
sb.append(value.toString()); sb.append(value.toString());

View file

@ -29,6 +29,7 @@ import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
/** /**
* User profile
* Created by gsantner (https://gsantner.github.io/) on 24.03.16. Part of Diaspora for Android. * Created by gsantner (https://gsantner.github.io/) on 24.03.16. Part of Diaspora for Android.
*/ */
public class PodUserProfile { public class PodUserProfile {
@ -36,8 +37,8 @@ public class PodUserProfile {
private Handler callbackHandler; private Handler callbackHandler;
private WebUserProfileChangedListener listener; private WebUserProfileChangedListener listener;
private App app; private final App app;
private AppSettings appSettings; private final AppSettings appSettings;
private JSONObject json; private JSONObject json;
private long lastLoaded; private long lastLoaded;
private boolean isWebUserProfileLoaded; private boolean isWebUserProfileLoaded;

View file

@ -40,8 +40,8 @@ import info.guardianproject.netcipher.NetCipher;
* Created by gsantner (https://gsantner.github.io/) on 24.03.16. * Created by gsantner (https://gsantner.github.io/) on 24.03.16.
*/ */
public class ImageDownloadTask extends AsyncTask<String, Void, Bitmap> { public class ImageDownloadTask extends AsyncTask<String, Void, Bitmap> {
ImageView imageView; private final ImageView imageView;
String savePath; private String savePath;
/** /**
* Download image from URL * Download image from URL

View file

@ -44,9 +44,9 @@ public class ProfileFetchTask extends AsyncTask<Void, Void, Void> {
// Code for getting the profile async without any UI/WebView // Code for getting the profile async without any UI/WebView
// TODO: This is an early version,needs to be converted to Service // TODO: This is an early version,needs to be converted to Service
final App app; private final App app;
final Context context; private final Context context;
final DiasporaUrlHelper urls; private final DiasporaUrlHelper urls;
public ProfileFetchTask(final App app) { public ProfileFetchTask(final App app) {
this.context = app.getApplicationContext(); this.context = app.getApplicationContext();

View file

@ -24,7 +24,6 @@ import android.util.Log;
import android.webkit.CookieManager; import android.webkit.CookieManager;
import com.github.dfa.diaspora_android.App; import com.github.dfa.diaspora_android.App;
import com.github.dfa.diaspora_android.data.PodUserProfile;
import com.github.dfa.diaspora_android.util.DiasporaUrlHelper; import com.github.dfa.diaspora_android.util.DiasporaUrlHelper;
import java.io.BufferedReader; import java.io.BufferedReader;
@ -44,9 +43,9 @@ public class StatisticsFetchTask extends AsyncTask<Void, Void, Void> {
// Code for getting the profile async without any UI/WebView // Code for getting the profile async without any UI/WebView
// TODO: This is an early version,needs to be converted to Service // TODO: This is an early version,needs to be converted to Service
final App app; private final App app;
final Context context; private final Context context;
final DiasporaUrlHelper urls; private final DiasporaUrlHelper urls;
public StatisticsFetchTask(final App app) { public StatisticsFetchTask(final App app) {
this.context = app.getApplicationContext(); this.context = app.getApplicationContext();

View file

@ -56,7 +56,7 @@ public class ContextMenuWebView extends NestedWebView {
public static final int ID_SHARE_LINK = 13; public static final int ID_SHARE_LINK = 13;
public static final int ID_SHARE_IMAGE = 14; public static final int ID_SHARE_IMAGE = 14;
private Context context; private final Context context;
private Activity parentActivity; private Activity parentActivity;
private String lasLoadUrl = ""; private String lasLoadUrl = "";

View file

@ -19,7 +19,6 @@
package com.github.dfa.diaspora_android.ui; package com.github.dfa.diaspora_android.ui;
import android.content.Intent; import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri; import android.net.Uri;
import android.webkit.CookieManager; import android.webkit.CookieManager;
import android.webkit.WebView; import android.webkit.WebView;
@ -28,7 +27,7 @@ import android.webkit.WebViewClient;
import com.github.dfa.diaspora_android.App; import com.github.dfa.diaspora_android.App;
public class CustomWebViewClient extends WebViewClient { public class CustomWebViewClient extends WebViewClient {
private App app; private final App app;
private WebView webView; private WebView webView;
public CustomWebViewClient(App app, WebView webView) { public CustomWebViewClient(App app, WebView webView) {

View file

@ -29,7 +29,7 @@ import com.github.dfa.diaspora_android.data.PodAspect;
*/ */
@SuppressWarnings("unused") @SuppressWarnings("unused")
public class DiasporaUrlHelper { public class DiasporaUrlHelper {
private AppSettings settings; private final AppSettings settings;
public static final String HTTPS = "https://"; public static final String HTTPS = "https://";
public static final String SUBURL_NOTIFICATIONS = "/notifications"; public static final String SUBURL_NOTIFICATIONS = "/notifications";

View file

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromYDelta="0%p" android:toYDelta="100%p" android:fillAfter="true"
android:interpolator="@android:anim/linear_interpolator"
android:duration="500" />
</set>

View file

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromYDelta="75%p" android:toYDelta="0%p"
android:fillAfter="true"
android:duration="500"/>
</set>

View file

@ -22,9 +22,9 @@
android:title="@string/action_share_dotdotdot" android:title="@string/action_share_dotdotdot"
app:showAsAction="always" > app:showAsAction="always" >
<menu> <menu>
<item android:id="@+id/action_share_screenshot" android:title="@string/share__share_screenshot"></item> <item android:id="@+id/action_share_screenshot" android:title="@string/share__share_screenshot"/>
<item android:id="@+id/action_take_screenshot" android:title="@string/share__take_screenshot"></item> <item android:id="@+id/action_take_screenshot" android:title="@string/share__take_screenshot"/>
<item android:id="@+id/action_share_link" android:title="@string/share__share_link_as_text"></item> <item android:id="@+id/action_share_link" android:title="@string/share__share_link_as_text"/>
</menu> </menu>
</item> </item>