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

Merge branch 'master' into poddy_as_podsource

This commit is contained in:
Gregor Santner 2016-10-07 14:36:50 +02:00
commit d9740d7275
8 changed files with 131 additions and 39 deletions

View file

@ -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;
}

View file

@ -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;

View file

@ -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>

View file

@ -21,13 +21,14 @@
<string name="pref_title__load_images">Lade Bilder</string>
<string name="pref_desc__load_images">Deaktiviere das Laden von Bildern, um den Datenverbrauch zu verringern</string>
<!-- Proxy -->
<string name="pref_title__sub_proxy">Proxy</string>
<string name="pref_title__proxy_enabled">Aktiviere Netzwerkproxy</string>
<string name="pref_desc__proxy_enabled">Nutze einen Proxyserver, um Firewalls zu umgehen</string>
<string name="pref_title__proxy_host">Host</string>
<string name="pref_title__proxy_port">Port</string>
<!-- Chrome custom tabs -->
<string name="pref_title__chrome_custom_tabs_enabled">Chrome Custom Tabs</string>
<string name="pref_desc__chrome_custom_tabs_enabled">Externe Links mit Chrome Custom Tabs öffnen. Für dieses Feature muss Chromium oder Google Chrome installiert sein</string>
<string name="pref_desc__chrome_custom_tabs_enabled">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!</string>
<!-- Diaspora Settings -->
<string name="pref_title__personal_settings">Persönliche Einstellungen</string>
<string name="pref_desc__personal_settings">Öffne die Einstellungen deines Diaspora Accounts</string>

View file

@ -28,7 +28,6 @@
<string name="pref_title__proxy_port">Port</string>
<!-- Chrome custom tabs -->
<string name="pref_title__chrome_custom_tabs_enabled">Onglets personnalisés de Chrome</string>
<string name="pref_desc__chrome_custom_tabs_enabled">Ouvrir les liens externes avec les onglets personnalisés. Chromium ou Google Chrome doit être installé pour cette fonctionnalité</string>
<!-- Diaspora Settings -->
<string name="pref_title__personal_settings">Paramètres personnels</string>
<string name="pref_desc__personal_settings">Ouvrir vos paramètres de compte diaspora</string>

View file

@ -22,14 +22,12 @@
<string name="pref_desc__load_images">Disabilita il caricamento delle immagini per risparmiare la rete dati</string>
<!-- Proxy -->
<string name="pref_title__sub_proxy">Proxy</string>
<string name="pref_desc__sub_proxy">@string/pref_desc__proxy_enabled</string>
<string name="pref_title__proxy_enabled">Attiva proxy</string>
<string name="pref_desc__proxy_enabled">Traffico del proxy di Diaspora per bypassare i firewall.\nPuò essere necessario il riavvio dell\'app</string>
<string name="pref_title__proxy_host">Host</string>
<string name="pref_title__proxy_port">Porta</string>
<!-- Chrome custom tabs -->
<string name="pref_title__chrome_custom_tabs_enabled">Schede personalizzate di Chrome</string>
<string name="pref_desc__chrome_custom_tabs_enabled">Apri collegamento esterno nelle schede personalizzate di Chrome. Per usare questa funzione Chromium o Google Chrome deve essere installato</string>
<!-- Diaspora Settings -->
<string name="pref_title__personal_settings">Impostazioni personali</string>
<string name="pref_desc__personal_settings">Apri le impostazioni del tuo account Diaspora</string>

View file

@ -22,14 +22,12 @@
<string name="pref_desc__load_images">安全なモバイルデータのため、画像の読み込みを無効にします</string>
<!-- Proxy -->
<string name="pref_title__sub_proxy">プロキシ</string>
<string name="pref_desc__sub_proxy">@string/pref_desc__proxy_enabled</string>
<string name="pref_title__proxy_enabled">プロキシを有効にする</string>
<string name="pref_desc__proxy_enabled">Diaspora の通信をプロキシして、ファイアウォールに回避します。\n再起動が必要になることがあります</string>
<string name="pref_title__proxy_host">ホスト</string>
<string name="pref_title__proxy_port">ポート</string>
<!-- Chrome custom tabs -->
<string name="pref_title__chrome_custom_tabs_enabled">Chrome カスタムタブ</string>
<string name="pref_desc__chrome_custom_tabs_enabled">Chrome カスタム タブで外部リンクを開きます。この機能は Chromium または Google Chrome をインストールする必要があります</string>
<!-- Diaspora Settings -->
<string name="pref_title__personal_settings">個人用設定</string>
<string name="pref_desc__personal_settings">Diaspora アカウント設定を開きます</string>

View file

@ -82,7 +82,7 @@
<!-- Proxy -->
<string name="pref_title__sub_proxy">Proxy</string>
<string name="pref_desc__sub_proxy">@string/pref_desc__proxy_enabled</string>
<string name="pref_desc__sub_proxy" translatable="false">@string/pref_desc__proxy_enabled</string>
<string name="pref_title__proxy_enabled">Enable Proxy</string>
<string name="pref_desc__proxy_enabled">Proxy Diaspora\'s traffic to circumvent firewalls.\nMay require restart</string>
<string name="pref_title__proxy_host">Host</string>
@ -91,7 +91,7 @@
<!-- Chrome custom tabs -->
<string name="pref_title__chrome_custom_tabs_enabled">Chrome Custom Tabs</string>
<string name="pref_desc__chrome_custom_tabs_enabled">Open external links with Chrome Custom Tabs. Chromium or Google Chrome needs to be installed for this feature</string>
<string name="pref_desc__chrome_custom_tabs_enabled">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!</string>
<!-- Diaspora Settings -->
<string name="pref_title__personal_settings">Personal settings</string>