1
0
Fork 0
mirror of https://github.com/gsantner/dandelion synced 2024-12-22 19:08:03 +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 {
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;
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";
private App app;
private String podDomain;
private ValueCallback<Uri[]> mFilePathCallback;
private String mCameraPhotoPath;
private WebSettings webSettings;
@ -132,7 +131,7 @@ public class MainActivity extends AppCompatActivity
private Snackbar snackbarExitApp;
private Snackbar snackbarNewNotification;
private Snackbar snackbarNoInternet;
public String textToBeShared = null;
private String textToBeShared = null;
/**
* UI Bindings
@ -233,7 +232,6 @@ public class MainActivity extends AppCompatActivity
setupNavigationSlider();
progressBar = (ProgressBar) findViewById(R.id.progressBar);
podDomain = appSettings.getPodDomain();
String url = urls.getPodUrl();
if (savedInstanceState == null) {
@ -864,7 +862,7 @@ public class MainActivity extends AppCompatActivity
app.getAvatarImageLoader().startImageDownload(navheaderImage, avatarUrl);
}
void handleSendText(Intent intent) {
private void handleSendText(Intent intent) {
String content = WebHelper.replaceUrlWithMarkdown(intent.getStringExtra(Intent.EXTRA_TEXT));
if (appSettings.isAppendSharedViaApp()) {
// &#10; = \n
@ -883,9 +881,9 @@ public class MainActivity extends AppCompatActivity
/**
* Handle sent text + subject
*
* @param intent
* @param intent intent
*/
void handleSendSubject(Intent intent) {
private void handleSendSubject(Intent intent) {
webView.loadUrlNew(urls.getNewPostUrl());
String content = WebHelper.replaceUrlWithMarkdown(intent.getStringExtra(Intent.EXTRA_TEXT));
String subject = WebHelper.replaceUrlWithMarkdown(intent.getStringExtra(Intent.EXTRA_SUBJECT));
@ -905,9 +903,9 @@ public class MainActivity extends AppCompatActivity
//TODO: Implement?
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) {
// 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();
}
@ -948,11 +946,6 @@ public class MainActivity extends AppCompatActivity
public void contentHasBeenShared() {
textToBeShared = null;
}
@JavascriptInterface
public void log(final String log) {
//Log.d(App.TAG, "[wv] " + log);
}
}
@SuppressWarnings("StatementWithEmptyBody")
@ -1062,6 +1055,7 @@ public class MainActivity extends AppCompatActivity
@Override
public void onClick(DialogInterface dialog, int item) {
if (options[item].equals(getString(R.string.help_license__name))) {
final SpannableString s = new SpannableString(Html.fromHtml(getString(R.string.help_license__content)));
Linkify.addLinks(s, Linkify.WEB_URLS);
final AlertDialog d = new AlertDialog.Builder(MainActivity.this)

View file

@ -60,13 +60,13 @@ public class PodSelectionActivity extends AppCompatActivity {
private App app;
@BindView(R.id.podselection__edit_filter)
public EditText editFilter;
EditText editFilter;
@BindView(R.id.podselection__listpods)
public ListView listPods;
ListView listPods;
@BindView(R.id.toolbar)
public Toolbar toolbar;
Toolbar toolbar;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -184,22 +184,21 @@ public class PodSelectionActivity extends AppCompatActivity {
.show();
}
public void onPodSelectionConfirmed(String selectedPod) {
private void onPodSelectionConfirmed(String 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().removeSessionCookies(null);
} catch (Exception e) {
e.printStackTrace();
}
} else {
try {
} else {
//noinspection deprecation
CookieManager.getInstance().removeAllCookie();
//noinspection deprecation
CookieManager.getInstance().removeSessionCookie();
} catch (Exception e) {
e.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
}
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();
}
public void setActivityRestartRequired(boolean b) {
this.activityRestartRequired = b;
private void setActivityRestartRequired() {
this.activityRestartRequired = true;
}
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_port)) ||
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.R;
import com.github.dfa.diaspora_android.util.Helpers;
import com.github.dfa.diaspora_android.util.WebHelper;
import butterknife.BindView;
import butterknife.ButterKnife;
@ -38,7 +37,7 @@ public class SplashActivity extends AppCompatActivity {
private App app;
@BindView(R.id.splash__splashimage)
public ImageView imgSplash;
ImageView imgSplash;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -56,7 +55,7 @@ public class SplashActivity extends AppCompatActivity {
new Handler().postDelayed(startActivityRunnable, delay);
}
final Runnable startActivityRunnable = new Runnable() {
private final Runnable startActivityRunnable = new Runnable() {
public void run() {
boolean hasPodDomain = app.getSettings().hasPodDomain();
Helpers.animateToActivity(SplashActivity.this,

View file

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

View file

@ -29,6 +29,7 @@ import org.json.JSONException;
import org.json.JSONObject;
/**
* User profile
* Created by gsantner (https://gsantner.github.io/) on 24.03.16. Part of Diaspora for Android.
*/
public class PodUserProfile {
@ -36,8 +37,8 @@ public class PodUserProfile {
private Handler callbackHandler;
private WebUserProfileChangedListener listener;
private App app;
private AppSettings appSettings;
private final App app;
private final AppSettings appSettings;
private JSONObject json;
private long lastLoaded;
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.
*/
public class ImageDownloadTask extends AsyncTask<String, Void, Bitmap> {
ImageView imageView;
String savePath;
private final ImageView imageView;
private String savePath;
/**
* 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
// TODO: This is an early version,needs to be converted to Service
final App app;
final Context context;
final DiasporaUrlHelper urls;
private final App app;
private final Context context;
private final DiasporaUrlHelper urls;
public ProfileFetchTask(final App app) {
this.context = app.getApplicationContext();

View file

@ -24,7 +24,6 @@ import android.util.Log;
import android.webkit.CookieManager;
import com.github.dfa.diaspora_android.App;
import com.github.dfa.diaspora_android.data.PodUserProfile;
import com.github.dfa.diaspora_android.util.DiasporaUrlHelper;
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
// TODO: This is an early version,needs to be converted to Service
final App app;
final Context context;
final DiasporaUrlHelper urls;
private final App app;
private final Context context;
private final DiasporaUrlHelper urls;
public StatisticsFetchTask(final App app) {
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_IMAGE = 14;
private Context context;
private final Context context;
private Activity parentActivity;
private String lasLoadUrl = "";

View file

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

View file

@ -29,7 +29,7 @@ import com.github.dfa.diaspora_android.data.PodAspect;
*/
@SuppressWarnings("unused")
public class DiasporaUrlHelper {
private AppSettings settings;
private final AppSettings settings;
public static final String HTTPS = "https://";
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"
app:showAsAction="always" >
<menu>
<item android:id="@+id/action_share_screenshot" android:title="@string/share__share_screenshot"></item>
<item android:id="@+id/action_take_screenshot" android:title="@string/share__take_screenshot"></item>
<item android:id="@+id/action_share_link" android:title="@string/share__share_link_as_text"></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 android:id="@+id/action_share_link" android:title="@string/share__share_link_as_text"/>
</menu>
</item>