diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 7b75d8d3..3ee52fa8 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -12,43 +12,26 @@
android:name="com.github.dfa.diaspora_android.App"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
+
-
-
-
-
-
-
-
-
+
+
-
+ android:label="@string/settings" />
-
-
+
+
+
+
+
+
@@ -255,9 +243,7 @@
-
+
+
\ No newline at end of file
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 44b06b45..f0a8995d 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
@@ -66,6 +66,7 @@ import com.github.dfa.diaspora_android.fragment.BrowserFragment;
import com.github.dfa.diaspora_android.fragment.CustomFragment;
import com.github.dfa.diaspora_android.fragment.DiasporaStreamFragment;
import com.github.dfa.diaspora_android.fragment.HashtagListFragment;
+import com.github.dfa.diaspora_android.fragment.PodSelectionFragment;
import com.github.dfa.diaspora_android.fragment.TestFragment;
import com.github.dfa.diaspora_android.listener.WebUserProfileChangedListener;
import com.github.dfa.diaspora_android.receiver.OpenExternalLinkReceiver;
@@ -179,12 +180,17 @@ public class MainActivity extends AppCompatActivity
MainActivity.this.setTitle(title);
}
});
- //Handle intent
- Intent intent = getIntent();
- if(intent != null && intent.getAction() != null) {
- handleIntent(intent);
+
+ if(!appSettings.hasPodDomain()) {
+ showFragment(getFragment(PodSelectionFragment.TAG));
} else {
- openDiasporaUrl(urls.getStreamUrl());
+ //Handle intent
+ Intent intent = getIntent();
+ if (intent != null && intent.getAction() != null) {
+ handleIntent(intent);
+ } else {
+ openDiasporaUrl(urls.getStreamUrl());
+ }
}
}
@@ -261,6 +267,10 @@ public class MainActivity extends AppCompatActivity
HashtagListFragment hlf = new HashtagListFragment();
fm.beginTransaction().add(hlf, fragmentTag).commit();
return hlf;
+ case PodSelectionFragment.TAG:
+ PodSelectionFragment psf = new PodSelectionFragment();
+ fm.beginTransaction().add(psf, fragmentTag).commit();
+ return psf;
case TestFragment.TAG:
default:
AppLog.e(this,"Invalid Fragment Tag: "+fragmentTag
@@ -388,9 +398,9 @@ public class MainActivity extends AppCompatActivity
AppLog.v(this, "Intent has a delicious URL for us: "+loadUrl);
}
} else if (ACTION_CHANGE_ACCOUNT.equals(action)) {
- AppLog.v(this, "Reset pod data and animate to PodSelectionActivity");
+ AppLog.v(this, "Reset pod data and show PodSelectionFragment");
app.resetPodData(((DiasporaStreamFragment) getFragment(DiasporaStreamFragment.TAG)).getWebView());
- Helpers.animateToActivity(MainActivity.this, PodSelectionActivity.class, true);
+ showFragment(getFragment(PodSelectionFragment.TAG));
} else if (ACTION_CLEAR_CACHE.equals(action)) {
AppLog.v(this, "Clear WebView cache");
((DiasporaStreamFragment) getFragment(DiasporaStreamFragment.TAG)).getWebView().clearCache(true);
@@ -510,13 +520,24 @@ public class MainActivity extends AppCompatActivity
@Override
public boolean onCreateOptionsMenu(Menu menu) {
AppLog.v(this, "onCreateOptionsMenu()");
+ //Clear the menus
menu.clear();
- getMenuInflater().inflate(R.menu.main__menu_top, menu);
toolbarBottom.getMenu().clear();
- getMenuInflater().inflate(R.menu.main__menu_bottom, toolbarBottom.getMenu());
+ toolbarBottom.setVisibility(View.VISIBLE);
+
CustomFragment top = getTopFragment();
if(top != null) {
- top.onCreateBottomOptionsMenu(toolbarBottom.getMenu(), getMenuInflater());
+ //Are we displaying a Fragment other than PodSelectionFragment?
+ if(!top.getFragmentTag().equals(PodSelectionFragment.TAG)) {
+ getMenuInflater().inflate(R.menu.main__menu_top, menu);
+ getMenuInflater().inflate(R.menu.main__menu_bottom, toolbarBottom.getMenu());
+ top.onCreateBottomOptionsMenu(toolbarBottom.getMenu(), getMenuInflater());
+ }
+ //PodSelectionFragment
+ else {
+ //Hide bottom toolbar
+ toolbarBottom.setVisibility(View.GONE);
+ }
}
return true;
}
diff --git a/app/src/main/java/com/github/dfa/diaspora_android/activity/SplashActivity.java b/app/src/main/java/com/github/dfa/diaspora_android/activity/SplashActivity.java
deleted file mode 100644
index 0eeccd3c..00000000
--- a/app/src/main/java/com/github/dfa/diaspora_android/activity/SplashActivity.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- This file is part of the Diaspora for Android.
-
- Diaspora for Android is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Diaspora for Android is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with the Diaspora for Android.
-
- If not, see .
- */
-
-package com.github.dfa.diaspora_android.activity;
-
-import android.os.Bundle;
-import android.os.Handler;
-import android.support.v7.app.AppCompatActivity;
-
-import com.github.dfa.diaspora_android.App;
-import com.github.dfa.diaspora_android.R;
-import com.github.dfa.diaspora_android.util.Helpers;
-
-import butterknife.ButterKnife;
-
-
-public class SplashActivity extends AppCompatActivity {
- private App app;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.splash__activity);
- ButterKnife.bind(this);
- app = (App) getApplication();
-
- int delay = getResources().getInteger(R.integer.splash_delay);
- new Handler().postDelayed(startActivityRunnable, delay);
- }
-
- private final Runnable startActivityRunnable = new Runnable() {
- public void run() {
- boolean hasPodDomain = app.getSettings().hasPodDomain();
- Helpers.animateToActivity(SplashActivity.this,
- hasPodDomain ? MainActivity.class : PodSelectionActivity.class,
- true
- );
- }
- };
-}
diff --git a/app/src/main/java/com/github/dfa/diaspora_android/activity/PodSelectionActivity.java b/app/src/main/java/com/github/dfa/diaspora_android/fragment/PodSelectionFragment.java
similarity index 58%
rename from app/src/main/java/com/github/dfa/diaspora_android/activity/PodSelectionActivity.java
rename to app/src/main/java/com/github/dfa/diaspora_android/fragment/PodSelectionFragment.java
index 57103f6b..d833d271 100644
--- a/app/src/main/java/com/github/dfa/diaspora_android/activity/PodSelectionActivity.java
+++ b/app/src/main/java/com/github/dfa/diaspora_android/fragment/PodSelectionFragment.java
@@ -1,22 +1,4 @@
-/*
- This file is part of the Diaspora for Android.
-
- Diaspora for Android is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Diaspora for Android is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with the Diaspora for Android.
-
- If not, see .
- */
-package com.github.dfa.diaspora_android.activity;
+package com.github.dfa.diaspora_android.fragment;
import android.app.AlertDialog;
import android.content.BroadcastReceiver;
@@ -28,64 +10,103 @@ import android.os.Build;
import android.os.Bundle;
import android.support.design.widget.Snackbar;
import android.support.v4.content.LocalBroadcastManager;
-import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.Toolbar;
import android.text.Editable;
import android.text.SpannableString;
import android.text.TextWatcher;
import android.text.util.Linkify;
+import android.view.LayoutInflater;
import android.view.Menu;
+import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
+import android.view.ViewGroup;
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 com.github.dfa.diaspora_android.App;
import com.github.dfa.diaspora_android.R;
+import com.github.dfa.diaspora_android.activity.MainActivity;
+import com.github.dfa.diaspora_android.data.AppSettings;
import com.github.dfa.diaspora_android.task.GetPodsService;
-import com.github.dfa.diaspora_android.util.Helpers;
+import com.github.dfa.diaspora_android.util.AppLog;
+import com.github.dfa.diaspora_android.util.DiasporaUrlHelper;
import com.github.dfa.diaspora_android.util.WebHelper;
import java.util.ArrayList;
-import butterknife.BindView;
-import butterknife.ButterKnife;
-import butterknife.OnClick;
-import butterknife.OnItemClick;
+/**
+ * Fragment that lets the user choose a Pod
+ * Created by vanitas on 01.10.16.
+ */
+public class PodSelectionFragment extends CustomFragment {
+ public static final String TAG = "com.github.dfa.diaspora_android.PodSelectionFragment";
-public class PodSelectionActivity extends AppCompatActivity {
- private App app;
+ protected EditText editFilter;
+ protected ListView listPods;
+ protected ImageView selectPodButton;
- @BindView(R.id.podselection__edit_filter)
- EditText editFilter;
-
- @BindView(R.id.podselection__listpods)
- ListView listPods;
-
- @BindView(R.id.main__topbar)
- Toolbar toolbar;
+ protected App app;
+ protected AppSettings appSettings;
@Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.podselection__activity);
- ButterKnife.bind(this);
- app = (App) getApplication();
- setSupportActionBar(toolbar);
-
-
- listPods.setTextFilterEnabled(true);
- setListedPods(app.getSettings().getPreviousPodlist());
- LocalBroadcastManager.getInstance(this).registerReceiver(podListReceiver, new IntentFilter(GetPodsService.MESSAGE_PODS_RECEIVED));
-
- if (!WebHelper.isOnline(PodSelectionActivity.this)) {
- Snackbar.make(listPods, R.string.no_internet, Snackbar.LENGTH_LONG).show();
- }
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ AppLog.d(this, "onCreateView()");
+ return inflater.inflate(R.layout.podselection__fragment, container, false);
}
+ @Override
+ public void onViewCreated(View view, Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+ this.app = (App) getActivity().getApplication();
+ this.appSettings = app.getSettings();
+
+ this.editFilter = (EditText) view.findViewById(R.id.podselection__edit_filter);
+ this.listPods = (ListView) view.findViewById(R.id.podselection__listpods);
+ this.selectPodButton = (ImageView) view.findViewById(R.id.podselection__button_select_pod);
+
+ listPods.setTextFilterEnabled(true);
+ listPods.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+ @Override
+ public void onItemClick(AdapterView> adapterView, View view, int i, long l) {
+ showPodConfirmationDialog((String) listPods.getAdapter().getItem(i));
+ }
+ });
+ setListedPods(appSettings.getPreviousPodlist());
+ LocalBroadcastManager.getInstance(getContext()).registerReceiver(podListReceiver, new IntentFilter(GetPodsService.MESSAGE_PODS_RECEIVED));
+ if (!WebHelper.isOnline(getContext())) {
+ Snackbar.make(listPods, R.string.no_internet, Snackbar.LENGTH_LONG).show();
+ }
+ selectPodButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ if (editFilter.getText().length() > 4 && editFilter.getText().toString().contains("")) {
+ showPodConfirmationDialog(editFilter.getText().toString());
+ } else {
+ Snackbar.make(listPods, R.string.valid_pod, Snackbar.LENGTH_LONG).show();
+ }
+ }
+ });
+ }
+
+ @Override
+ public String getFragmentTag() {
+ return TAG;
+ }
+
+ @Override
+ public void onCreateBottomOptionsMenu(Menu menu, MenuInflater inflater) {
+ /* Nothing to do */
+ }
+
+ @Override
+ public boolean onBackPressed() {
+ return false;
+ }
private final BroadcastReceiver podListReceiver = new BroadcastReceiver() {
@Override
@@ -104,20 +125,11 @@ public class PodSelectionActivity extends AppCompatActivity {
}
};
- @OnClick(R.id.podselection__button_select_pod)
- public void onButtonSelectPodClicked(View view) {
- if (editFilter.getText().length() > 4 && editFilter.getText().toString().contains("")) {
- showPodConfirmationDialog(editFilter.getText().toString());
- } else {
- Snackbar.make(listPods, R.string.valid_pod, Snackbar.LENGTH_LONG).show();
- }
- }
-
@Override
- protected void onResume() {
+ public void onResume() {
super.onResume();
- Intent i = new Intent(PodSelectionActivity.this, GetPodsService.class);
- startService(i);
+ Intent i = new Intent(getContext(), GetPodsService.class);
+ getContext().startService(i);
}
@@ -128,7 +140,7 @@ public class PodSelectionActivity extends AppCompatActivity {
}
final ArrayAdapter adapter = new ArrayAdapter<>(
- PodSelectionActivity.this,
+ getContext(),
android.R.layout.simple_list_item_1,
listedPodsList);
@@ -154,24 +166,19 @@ public class PodSelectionActivity extends AppCompatActivity {
});
}
- @OnItemClick(R.id.podselection__listpods)
- public void onListPodsItemClicked(int position) {
- showPodConfirmationDialog((String) listPods.getAdapter().getItem(position));
- }
-
private void showPodConfirmationDialog(final String selectedPod) {
// Make a clickable link
final SpannableString dialogMessage = new SpannableString(getString(R.string.confirm_pod, selectedPod));
Linkify.addLinks(dialogMessage, Linkify.ALL);
// Check if online
- if (!WebHelper.isOnline(PodSelectionActivity.this)) {
+ if (!WebHelper.isOnline(getContext())) {
Snackbar.make(listPods, R.string.no_internet, Snackbar.LENGTH_LONG).show();
return;
}
// Show dialog
- new AlertDialog.Builder(PodSelectionActivity.this)
+ new AlertDialog.Builder(getContext())
.setTitle(getString(R.string.confirmation))
.setMessage(dialogMessage)
.setPositiveButton(android.R.string.yes,
@@ -201,40 +208,28 @@ public class PodSelectionActivity extends AppCompatActivity {
e.printStackTrace();
}
- Helpers.animateToActivity(this, MainActivity.class, true);
- }
-
-
- @Override
- public void onBackPressed() {
- Snackbar.make(listPods, R.string.confirm_exit, Snackbar.LENGTH_LONG)
- .setAction(android.R.string.yes, new View.OnClickListener() {
- public void onClick(View view) {
- finish();
- }
- })
- .show();
+ ((MainActivity)getActivity()).openDiasporaUrl(new DiasporaUrlHelper(appSettings).getPodUrl());
}
@Override
- protected void onDestroy() {
- LocalBroadcastManager.getInstance(this).unregisterReceiver(podListReceiver);
+ public void onDestroy() {
+ LocalBroadcastManager.getInstance(getContext()).unregisterReceiver(podListReceiver);
super.onDestroy();
}
@Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.podselection__menu, menu);
- return true;
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+ inflater.inflate(R.menu.podselection__menu, menu);
+ super.onCreateOptionsMenu(menu, inflater);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_reload: {
- if (WebHelper.isOnline(PodSelectionActivity.this)) {
- Intent i = new Intent(PodSelectionActivity.this, GetPodsService.class);
- startService(i);
+ if (WebHelper.isOnline(getContext())) {
+ Intent i = new Intent(getContext(), GetPodsService.class);
+ getContext().startService(i);
return true;
} else {
Snackbar.make(listPods, R.string.no_internet, Snackbar.LENGTH_LONG).show();
diff --git a/app/src/main/res/layout/podselection__activity.xml b/app/src/main/res/layout/podselection__activity.xml
deleted file mode 100644
index f93ce7f9..00000000
--- a/app/src/main/res/layout/podselection__activity.xml
+++ /dev/null
@@ -1,88 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/podselection__fragment.xml b/app/src/main/res/layout/podselection__fragment.xml
new file mode 100644
index 00000000..b8e39ac4
--- /dev/null
+++ b/app/src/main/res/layout/podselection__fragment.xml
@@ -0,0 +1,65 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/menu/podselection__menu.xml b/app/src/main/res/menu/podselection__menu.xml
index 1c33e1c9..8b498aa3 100644
--- a/app/src/main/res/menu/podselection__menu.xml
+++ b/app/src/main/res/menu/podselection__menu.xml
@@ -1,7 +1,5 @@