diff --git a/app/src/main/java/com/github/dfa/diaspora_android/activity/MainActivity.java b/app/src/main/java/com/github/dfa/diaspora_android/activity/MainActivity.java
index c0dcadbe..fd84990b 100644
--- a/app/src/main/java/com/github/dfa/diaspora_android/activity/MainActivity.java
+++ b/app/src/main/java/com/github/dfa/diaspora_android/activity/MainActivity.java
@@ -77,7 +77,6 @@ import com.github.dfa.diaspora_android.util.WebHelper;
import butterknife.BindView;
import butterknife.ButterKnife;
-import butterknife.OnClick;
public class MainActivity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener, WebUserProfileChangedListener, CustomTabActivityHelper.ConnectionCallback {
@@ -163,18 +162,24 @@ public class MainActivity extends AppCompatActivity
customTabActivityHelper.setConnectionCallback(this);
fm = getSupportFragmentManager();
- setupUI(savedInstanceState);
+ setupUI();
brOpenExternalLink = new OpenExternalLinkReceiver(this);
brSetTitle = new UpdateTitleReceiver(app, urls, new UpdateTitleReceiver.TitleCallback() {
@Override
public void setTitle(int rId) {
- MainActivity.this.setTitle(rId);
+ CustomFragment top = getTopFragment();
+ if (top != null && top.getFragmentTag().equals(DiasporaStreamFragment.TAG)) {
+ MainActivity.this.setTitle(rId);
+ }
}
@Override
public void setTitle(String title) {
- MainActivity.this.setTitle(title);
+ CustomFragment top = getTopFragment();
+ if (top != null && top.getFragmentTag().equals(DiasporaStreamFragment.TAG)) {
+ MainActivity.this.setTitle(title);
+ }
}
});
@@ -193,7 +198,11 @@ public class MainActivity extends AppCompatActivity
}
}
- private void setupUI(Bundle savedInstanceState) {
+ /**
+ * Setup the user interface. Set up both toolbars and initialize the snackbars.
+ * Initialize the navigation drawer and apply intellihide settings.
+ */
+ private void setupUI() {
AppLog.i(this, "setupUI()");
// Setup toolbar
@@ -245,7 +254,7 @@ public class MainActivity extends AppCompatActivity
/**
* Get an instance of the CustomFragment with the tag fragmentTag.
* If there was no instance so far, create a new one and add it to the FragmentManagers pool.
- * If there is no Fragment with the corresponding Tag, return null.
+ * If there is no Fragment with the corresponding Tag, return the top fragment.
*
* @param fragmentTag tag
* @return corresponding Fragment
@@ -297,6 +306,9 @@ public class MainActivity extends AppCompatActivity
}
}
+ /**
+ * Initialize the navigation slider
+ */
private void setupNavigationSlider() {
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, navDrawer, toolbarTop, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
@@ -348,19 +360,22 @@ public class MainActivity extends AppCompatActivity
}
}
- @OnClick(R.id.main__topbar)
- public void onToolBarClicked(View view) {
- AppLog.i(this, "onToolBarClicked()");
- onNavigationItemSelected(navView.getMenu().findItem(R.id.nav_stream));
- }
-
+ /**
+ * Forward incoming intents to handleIntent()
+ *
+ * @param intent incoming
+ */
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
-
handleIntent(intent);
}
+ /**
+ * Handle intents and execute intent specific actions
+ *
+ * @param intent intent to get handled
+ */
private void handleIntent(Intent intent) {
AppLog.i(this, "handleIntent()");
if (intent == null) {
@@ -411,7 +426,8 @@ public class MainActivity extends AppCompatActivity
break;
}
} else if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null) {
- //TODO: Implement and add filter to manifest
+ /* TODO: Implement and add filter to manifest */
+ return;
}
if (loadUrl != null) {
@@ -420,24 +436,24 @@ public class MainActivity extends AppCompatActivity
}
}
+ /**
+ * Handle activity results
+ *
+ * @param requestCode reqCode
+ * @param resultCode resCode
+ * @param data data
+ */
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
AppLog.v(this, "onActivityResult(): " + requestCode);
super.onActivityResult(requestCode, resultCode, data);
}
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- AppLog.v(this, "onSaveInstanceState()");
- super.onSaveInstanceState(outState);
- }
-
- @Override
- protected void onRestoreInstanceState(@NonNull Bundle savedInstanceState) {
- AppLog.v(this, "onRestoreInstanceState()");
- super.onRestoreInstanceState(savedInstanceState);
- }
-
+ /**
+ * Return the fragment which is currently displayed in R.id.fragment_container
+ *
+ * @return top fragment or null if there is none displayed
+ */
private CustomFragment getTopFragment() {
Fragment top = fm.findFragmentById(R.id.fragment_container);
if (top != null) {
@@ -446,6 +462,9 @@ public class MainActivity extends AppCompatActivity
return null;
}
+ /**
+ * Handle presses on the back button
+ */
@Override
public void onBackPressed() {
AppLog.v(this, "onBackPressed()");
@@ -506,6 +525,13 @@ public class MainActivity extends AppCompatActivity
LocalBroadcastManager.getInstance(this).registerReceiver(brOpenExternalLink, new IntentFilter(ACTION_OPEN_EXTERNAL_URL));
}
+ /**
+ * Clear and repopulate top and bottom toolbar.
+ * Also add menu items of the displayed fragment
+ *
+ * @param menu top toolbar
+ * @return boolean
+ */
@Override
public boolean onCreateOptionsMenu(Menu menu) {
AppLog.v(this, "onCreateOptionsMenu()");
@@ -531,10 +557,15 @@ public class MainActivity extends AppCompatActivity
return true;
}
+ /**
+ * Set the notification and messages counter in the top toolbar
+ *
+ * @param menu menu
+ * @return boolean
+ */
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
- MenuItem item;
-
+ // Navigation slider
Menu navMenu = navView.getMenu();
navMenu.findItem(R.id.nav_exit).setVisible(appSettings.isVisibleInNavExit());
navMenu.findItem(R.id.nav_activities).setVisible(appSettings.isVisibleInNavActivities());
@@ -546,6 +577,9 @@ public class MainActivity extends AppCompatActivity
navMenu.findItem(R.id.nav_mentions).setVisible(appSettings.isVisibleInNavMentions());
navMenu.findItem(R.id.nav_profile).setVisible(appSettings.isVisibleInNavProfile());
navMenu.findItem(R.id.nav_public).setVisible(appSettings.isVisibleInNavPublic_activities());
+
+ // Top bar
+ MenuItem item;
if (appSettings.getPod() == null) {
navMenu.setGroupVisible(navView.getMenu().findItem(R.id.nav_exit).getGroupId(), false);
}
@@ -562,6 +596,12 @@ public class MainActivity extends AppCompatActivity
return super.onPrepareOptionsMenu(menu);
}
+ /**
+ * Handle clicks on the optionsmenu
+ *
+ * @param item item
+ * @return boolean
+ */
@Override
public boolean onOptionsItemSelected(MenuItem item) {
AppLog.i(this, "onOptionsItemSelected()");
@@ -655,18 +695,33 @@ public class MainActivity extends AppCompatActivity
return super.onOptionsItemSelected(item);
}
+ /**
+ * Update the profile name in the navigation slider
+ *
+ * @param name name
+ */
@Override
public void onUserProfileNameChanged(String name) {
AppLog.i(this, "onUserProfileNameChanged()");
navheaderTitle.setText(name);
}
+ /**
+ * Update the profile picture in the navigation slider
+ *
+ * @param avatarUrl url of the new profile pic
+ */
@Override
public void onUserProfileAvatarChanged(String avatarUrl) {
AppLog.i(this, "onUserProfileAvatarChanged()");
app.getAvatarImageLoader().startImageDownload(navheaderImage, avatarUrl);
}
+ /**
+ * Handle hashtag clicks. Open the new-post-url and inject the clicked hashtag into the post-editor
+ *
+ * @param intent intent
+ */
private void handleHashtag(Intent intent) {
AppLog.v(this, "handleHashtag()");
try {
@@ -677,6 +732,11 @@ public class MainActivity extends AppCompatActivity
openDiasporaUrl(urls.getNewPostUrl());
}
+ /**
+ * Open the new-post-url and inject text that was shared into the app into the post editors text field
+ *
+ * @param intent shareTextIntent
+ */
private void handleSendText(Intent intent) {
AppLog.v(this, "handleSendText()");
try {
@@ -731,6 +791,11 @@ public class MainActivity extends AppCompatActivity
}
}
+ /**
+ * Share an image shared to the app via diaspora
+ *
+ * @param intent shareImageIntent
+ */
//TODO: Implement some day
private void handleSendImage(Intent intent) {
AppLog.i(this, "handleSendImage()");
@@ -743,6 +808,11 @@ public class MainActivity extends AppCompatActivity
Toast.makeText(this, "Not yet implemented.", Toast.LENGTH_SHORT).show();
}
+ /**
+ * Invalidate the top toolbar to update the notification counter
+ *
+ * @param notificationCount new notification count
+ */
@Override
public void onNotificationCountChanged(int notificationCount) {
AppLog.i(this, "onNotificationCountChanged()");
@@ -750,6 +820,11 @@ public class MainActivity extends AppCompatActivity
invalidateOptionsMenu();
}
+ /**
+ * Invalidate the top toolbar to update the unread messages counter
+ *
+ * @param unreadMessageCount new unread messages count
+ */
@Override
public void onUnreadMessageCountChanged(int unreadMessageCount) {
AppLog.i(this, "onUnreadMessageCountChanged()");
@@ -878,6 +953,13 @@ public class MainActivity extends AppCompatActivity
return true;
}
+ /**
+ * React to results of requestPermission
+ *
+ * @param requestCode resCode
+ * @param permissions requested permissions
+ * @param grantResults granted results
+ */
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
switch (requestCode) {
@@ -897,10 +979,20 @@ public class MainActivity extends AppCompatActivity
}
}
+ /**
+ * Return the string that will be shared into the new-post-editor
+ *
+ * @return String
+ */
public String getTextToBeShared() {
return textToBeShared;
}
+ /**
+ * Set the string that will be shared into the new-post-editor
+ *
+ * @param textToBeShared
+ */
public void setTextToBeShared(String textToBeShared) {
this.textToBeShared = textToBeShared;
}
diff --git a/app/src/main/java/com/github/dfa/diaspora_android/activity/SettingsActivity.java b/app/src/main/java/com/github/dfa/diaspora_android/activity/SettingsActivity.java
index 322f5f06..b4b725a3 100644
--- a/app/src/main/java/com/github/dfa/diaspora_android/activity/SettingsActivity.java
+++ b/app/src/main/java/com/github/dfa/diaspora_android/activity/SettingsActivity.java
@@ -97,8 +97,7 @@ public class SettingsActivity extends AppCompatActivity {
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
updatePreference(findPreference(key));
- if (key != null && isAdded() && (key.equals(getString(R.string.pref_key__clear_cache)) ||
- key.equals(getString(R.string.pref_key__font_size)) ||
+ if (key != null && isAdded() && (key.equals(getString(R.string.pref_key__font_size)) ||
key.equals(getString(R.string.pref_key__load_images)) ||
key.equals(getString(R.string.pref_key__intellihide_toolbars)) ||
key.equals(getString(R.string.pref_key__proxy_enabled)) ||
@@ -162,6 +161,11 @@ public class SettingsActivity extends AppCompatActivity {
.show();
return true;
}
+ case R.string.pref_title__clear_cache:
+ {
+ intent.setAction(MainActivity.ACTION_CLEAR_CACHE);
+ break;
+ }
default: {
intent = null;
diff --git a/app/src/main/res/values-de/strings-about.xml b/app/src/main/res/values-de/strings-about.xml
index 7a85ecae..c2ffbd61 100644
--- a/app/src/main/res/values-de/strings-about.xml
+++ b/app/src/main/res/values-de/strings-about.xml
@@ -24,7 +24,7 @@
Diaspora benutzt Markdown-Formatierung für deine Beiträge. Weitere Informationen dazu findest du auf<br>
https://wiki.diasporafoundation.org/Markdown_reference_guide <br> <br>
- DiasporaForAndroid wird unabhängig und frei wie in Freiheit entwickelt und folgt den Ideen des Diaspora Projektes. <br>
+ DiasporaForAndroid wird frei wie in Freiheit entwickelt und folgt den Ideen des Diaspora Projektes. <br>
Den Quellcode findest du auf Github: <br>
https://github.com/Diaspora-for-Android/diaspora-android <br> <br>
diff --git a/app/src/main/res/values-de/strings-preferences.xml b/app/src/main/res/values-de/strings-preferences.xml
index ed3586f7..b65a1f78 100644
--- a/app/src/main/res/values-de/strings-preferences.xml
+++ b/app/src/main/res/values-de/strings-preferences.xml
@@ -21,13 +21,14 @@
Lade Bilder
Deaktiviere das Laden von Bildern, um den Datenverbrauch zu verringern
+ Proxy
Aktiviere Netzwerkproxy
Nutze einen Proxyserver, um Firewalls zu umgehen
Host
Port
Chrome Custom Tabs
- Externe Links mit Chrome Custom Tabs öffnen. Für dieses Feature muss Chromium oder Google Chrome installiert sein
+ Externe Links mit Chrome Custom Tabs öffnen. Chromium oder Google Chrome muss für dieses Feature installiert sein.\nWICHTIGER HINWEIS: Chrome Custom Tabs verwenden die konfigurierten Proxy-Server nicht!
Persönliche Einstellungen
Öffne die Einstellungen deines Diaspora Accounts
diff --git a/app/src/main/res/values-fr/strings-preferences.xml b/app/src/main/res/values-fr/strings-preferences.xml
index 0406f8e6..0ea412ca 100644
--- a/app/src/main/res/values-fr/strings-preferences.xml
+++ b/app/src/main/res/values-fr/strings-preferences.xml
@@ -28,7 +28,6 @@
Port
Onglets personnalisés de Chrome
- Ouvrir les liens externes avec les onglets personnalisés. Chromium ou Google Chrome doit être installé pour cette fonctionnalité
Paramètres personnels
Ouvrir vos paramètres de compte diaspora
diff --git a/app/src/main/res/values-it/strings-preferences.xml b/app/src/main/res/values-it/strings-preferences.xml
index 71aa9c99..616a76fe 100644
--- a/app/src/main/res/values-it/strings-preferences.xml
+++ b/app/src/main/res/values-it/strings-preferences.xml
@@ -22,14 +22,12 @@
Disabilita il caricamento delle immagini per risparmiare la rete dati
Proxy
- @string/pref_desc__proxy_enabled
Attiva proxy
Traffico del proxy di Diaspora per bypassare i firewall.\nPuò essere necessario il riavvio dell\'app
Host
Porta
Schede personalizzate di Chrome
- Apri collegamento esterno nelle schede personalizzate di Chrome. Per usare questa funzione Chromium o Google Chrome deve essere installato
Impostazioni personali
Apri le impostazioni del tuo account Diaspora
diff --git a/app/src/main/res/values-ja/strings-preferences.xml b/app/src/main/res/values-ja/strings-preferences.xml
index 2d88e3e2..0303f57f 100644
--- a/app/src/main/res/values-ja/strings-preferences.xml
+++ b/app/src/main/res/values-ja/strings-preferences.xml
@@ -22,14 +22,12 @@
安全なモバイルデータのため、画像の読み込みを無効にします
プロキシ
- @string/pref_desc__proxy_enabled
プロキシを有効にする
Diaspora の通信をプロキシして、ファイアウォールに回避します。\n再起動が必要になることがあります
ホスト
ポート
Chrome カスタムタブ
- Chrome カスタム タブで外部リンクを開きます。この機能は Chromium または Google Chrome をインストールする必要があります
個人用設定
Diaspora アカウント設定を開きます
diff --git a/app/src/main/res/values/strings-preferences.xml b/app/src/main/res/values/strings-preferences.xml
index 1bf858aa..66fbdc29 100644
--- a/app/src/main/res/values/strings-preferences.xml
+++ b/app/src/main/res/values/strings-preferences.xml
@@ -82,7 +82,7 @@
Proxy
- @string/pref_desc__proxy_enabled
+ @string/pref_desc__proxy_enabled
Enable Proxy
Proxy Diaspora\'s traffic to circumvent firewalls.\nMay require restart
Host
@@ -91,7 +91,7 @@
Chrome Custom Tabs
- Open external links with Chrome Custom Tabs. Chromium or Google Chrome needs to be installed for this feature
+ Open external links with Chrome Custom Tabs. Chromium or Google Chrome needs to be installed for this feature. \nIMPORTANT NOTE: Chrome Custom Tabs do not use configured proxy servers!
Personal settings