mirror of
https://github.com/gsantner/dandelion
synced 2024-11-22 12:22:08 +01:00
Removed SplashActivity, migrated PodSelectionActivity to PodSelectionFragment
This commit is contained in:
parent
e06e2f3ba1
commit
94895f78e0
7 changed files with 202 additions and 281 deletions
|
@ -12,43 +12,26 @@
|
||||||
android:name="com.github.dfa.diaspora_android.App"
|
android:name="com.github.dfa.diaspora_android.App"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:theme="@style/AppTheme" >
|
android:theme="@style/AppTheme" >
|
||||||
|
|
||||||
<provider
|
<provider
|
||||||
android:name="com.github.dfa.diaspora_android.data.HashtagProvider"
|
android:name="com.github.dfa.diaspora_android.data.HashtagProvider"
|
||||||
android:authorities="com.github.dfa.diaspora_android.mainactivity" />
|
android:authorities="com.github.dfa.diaspora_android.mainactivity" />
|
||||||
<activity
|
|
||||||
android:name="com.github.dfa.diaspora_android.activity.SplashActivity"
|
<service
|
||||||
android:launchMode="singleInstance"
|
android:name="com.github.dfa.diaspora_android.task.GetPodsService"
|
||||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
android:enabled="true"
|
||||||
android:label="@string/app_name"
|
android:exported="false" />
|
||||||
android:screenOrientation="portrait"
|
|
||||||
android:theme="@style/Theme.AppCompat.NoActionBar">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
|
||||||
<activity
|
|
||||||
android:name=".activity.PodSelectionActivity"
|
|
||||||
android:launchMode="singleInstance"
|
|
||||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
|
||||||
android:label="@string/title_activity_pods"
|
|
||||||
android:screenOrientation="portrait"
|
|
||||||
android:theme="@style/AppTheme.NoActionBar"
|
|
||||||
android:windowSoftInputMode="stateHidden" >
|
|
||||||
</activity>
|
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.SettingsActivity"
|
android:name=".activity.SettingsActivity"
|
||||||
android:launchMode="singleInstance"
|
android:launchMode="singleInstance"
|
||||||
android:theme="@style/AppTheme"
|
android:theme="@style/AppTheme"
|
||||||
android:label="@string/settings">
|
android:label="@string/settings" />
|
||||||
</activity>
|
|
||||||
|
|
||||||
<service
|
<activity
|
||||||
android:name="com.github.dfa.diaspora_android.task.GetPodsService"
|
android:name=".activity.AboutActivity"
|
||||||
android:enabled="true"
|
android:label="@string/about_activity__title_about_app"
|
||||||
android:exported="false" >
|
android:theme="@style/AppTheme.NoActionBar"/>
|
||||||
</service>
|
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.MainActivity"
|
android:name=".activity.MainActivity"
|
||||||
|
@ -58,6 +41,11 @@
|
||||||
android:theme="@style/AppTheme.NoActionBar"
|
android:theme="@style/AppTheme.NoActionBar"
|
||||||
android:label="@string/diaspora">
|
android:label="@string/diaspora">
|
||||||
|
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.SEND" />
|
<action android:name="android.intent.action.SEND" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
@ -255,9 +243,7 @@
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
|
||||||
android:name=".activity.AboutActivity"
|
|
||||||
android:label="@string/about_activity__title_about_app"
|
|
||||||
android:theme="@style/AppTheme.NoActionBar"/>
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
|
@ -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.CustomFragment;
|
||||||
import com.github.dfa.diaspora_android.fragment.DiasporaStreamFragment;
|
import com.github.dfa.diaspora_android.fragment.DiasporaStreamFragment;
|
||||||
import com.github.dfa.diaspora_android.fragment.HashtagListFragment;
|
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.fragment.TestFragment;
|
||||||
import com.github.dfa.diaspora_android.listener.WebUserProfileChangedListener;
|
import com.github.dfa.diaspora_android.listener.WebUserProfileChangedListener;
|
||||||
import com.github.dfa.diaspora_android.receiver.OpenExternalLinkReceiver;
|
import com.github.dfa.diaspora_android.receiver.OpenExternalLinkReceiver;
|
||||||
|
@ -179,14 +180,19 @@ public class MainActivity extends AppCompatActivity
|
||||||
MainActivity.this.setTitle(title);
|
MainActivity.this.setTitle(title);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if(!appSettings.hasPodDomain()) {
|
||||||
|
showFragment(getFragment(PodSelectionFragment.TAG));
|
||||||
|
} else {
|
||||||
//Handle intent
|
//Handle intent
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
if(intent != null && intent.getAction() != null) {
|
if (intent != null && intent.getAction() != null) {
|
||||||
handleIntent(intent);
|
handleIntent(intent);
|
||||||
} else {
|
} else {
|
||||||
openDiasporaUrl(urls.getStreamUrl());
|
openDiasporaUrl(urls.getStreamUrl());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void setupUI(Bundle savedInstanceState) {
|
private void setupUI(Bundle savedInstanceState) {
|
||||||
AppLog.i(this, "setupUI()");
|
AppLog.i(this, "setupUI()");
|
||||||
|
@ -261,6 +267,10 @@ public class MainActivity extends AppCompatActivity
|
||||||
HashtagListFragment hlf = new HashtagListFragment();
|
HashtagListFragment hlf = new HashtagListFragment();
|
||||||
fm.beginTransaction().add(hlf, fragmentTag).commit();
|
fm.beginTransaction().add(hlf, fragmentTag).commit();
|
||||||
return hlf;
|
return hlf;
|
||||||
|
case PodSelectionFragment.TAG:
|
||||||
|
PodSelectionFragment psf = new PodSelectionFragment();
|
||||||
|
fm.beginTransaction().add(psf, fragmentTag).commit();
|
||||||
|
return psf;
|
||||||
case TestFragment.TAG:
|
case TestFragment.TAG:
|
||||||
default:
|
default:
|
||||||
AppLog.e(this,"Invalid Fragment Tag: "+fragmentTag
|
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);
|
AppLog.v(this, "Intent has a delicious URL for us: "+loadUrl);
|
||||||
}
|
}
|
||||||
} else if (ACTION_CHANGE_ACCOUNT.equals(action)) {
|
} 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());
|
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)) {
|
} else if (ACTION_CLEAR_CACHE.equals(action)) {
|
||||||
AppLog.v(this, "Clear WebView cache");
|
AppLog.v(this, "Clear WebView cache");
|
||||||
((DiasporaStreamFragment) getFragment(DiasporaStreamFragment.TAG)).getWebView().clearCache(true);
|
((DiasporaStreamFragment) getFragment(DiasporaStreamFragment.TAG)).getWebView().clearCache(true);
|
||||||
|
@ -510,14 +520,25 @@ public class MainActivity extends AppCompatActivity
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
AppLog.v(this, "onCreateOptionsMenu()");
|
AppLog.v(this, "onCreateOptionsMenu()");
|
||||||
|
//Clear the menus
|
||||||
menu.clear();
|
menu.clear();
|
||||||
getMenuInflater().inflate(R.menu.main__menu_top, menu);
|
|
||||||
toolbarBottom.getMenu().clear();
|
toolbarBottom.getMenu().clear();
|
||||||
getMenuInflater().inflate(R.menu.main__menu_bottom, toolbarBottom.getMenu());
|
toolbarBottom.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
CustomFragment top = getTopFragment();
|
CustomFragment top = getTopFragment();
|
||||||
if(top != null) {
|
if(top != null) {
|
||||||
|
//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());
|
top.onCreateBottomOptionsMenu(toolbarBottom.getMenu(), getMenuInflater());
|
||||||
}
|
}
|
||||||
|
//PodSelectionFragment
|
||||||
|
else {
|
||||||
|
//Hide bottom toolbar
|
||||||
|
toolbarBottom.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
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
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -1,22 +1,4 @@
|
||||||
/*
|
package com.github.dfa.diaspora_android.fragment;
|
||||||
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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package com.github.dfa.diaspora_android.activity;
|
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
|
@ -28,64 +10,103 @@ import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.design.widget.Snackbar;
|
import android.support.design.widget.Snackbar;
|
||||||
import android.support.v4.content.LocalBroadcastManager;
|
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.Editable;
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
import android.text.util.Linkify;
|
import android.text.util.Linkify;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
import android.webkit.CookieManager;
|
import android.webkit.CookieManager;
|
||||||
|
import android.widget.AdapterView;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
|
|
||||||
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.activity.MainActivity;
|
||||||
|
import com.github.dfa.diaspora_android.data.AppSettings;
|
||||||
import com.github.dfa.diaspora_android.task.GetPodsService;
|
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 com.github.dfa.diaspora_android.util.WebHelper;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import butterknife.BindView;
|
/**
|
||||||
import butterknife.ButterKnife;
|
* Fragment that lets the user choose a Pod
|
||||||
import butterknife.OnClick;
|
* Created by vanitas on 01.10.16.
|
||||||
import butterknife.OnItemClick;
|
*/
|
||||||
|
|
||||||
|
public class PodSelectionFragment extends CustomFragment {
|
||||||
|
public static final String TAG = "com.github.dfa.diaspora_android.PodSelectionFragment";
|
||||||
|
|
||||||
public class PodSelectionActivity extends AppCompatActivity {
|
protected EditText editFilter;
|
||||||
private App app;
|
protected ListView listPods;
|
||||||
|
protected ImageView selectPodButton;
|
||||||
|
|
||||||
@BindView(R.id.podselection__edit_filter)
|
protected App app;
|
||||||
EditText editFilter;
|
protected AppSettings appSettings;
|
||||||
|
|
||||||
@BindView(R.id.podselection__listpods)
|
|
||||||
ListView listPods;
|
|
||||||
|
|
||||||
@BindView(R.id.main__topbar)
|
|
||||||
Toolbar toolbar;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
AppLog.d(this, "onCreateView()");
|
||||||
setContentView(R.layout.podselection__activity);
|
return inflater.inflate(R.layout.podselection__fragment, container, false);
|
||||||
ButterKnife.bind(this);
|
}
|
||||||
app = (App) getApplication();
|
|
||||||
setSupportActionBar(toolbar);
|
|
||||||
|
|
||||||
|
@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.setTextFilterEnabled(true);
|
||||||
setListedPods(app.getSettings().getPreviousPodlist());
|
listPods.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
LocalBroadcastManager.getInstance(this).registerReceiver(podListReceiver, new IntentFilter(GetPodsService.MESSAGE_PODS_RECEIVED));
|
@Override
|
||||||
|
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
||||||
if (!WebHelper.isOnline(PodSelectionActivity.this)) {
|
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();
|
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() {
|
private final BroadcastReceiver podListReceiver = new BroadcastReceiver() {
|
||||||
@Override
|
@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
|
@Override
|
||||||
protected void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
Intent i = new Intent(PodSelectionActivity.this, GetPodsService.class);
|
Intent i = new Intent(getContext(), GetPodsService.class);
|
||||||
startService(i);
|
getContext().startService(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -128,7 +140,7 @@ public class PodSelectionActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
final ArrayAdapter<String> adapter = new ArrayAdapter<>(
|
final ArrayAdapter<String> adapter = new ArrayAdapter<>(
|
||||||
PodSelectionActivity.this,
|
getContext(),
|
||||||
android.R.layout.simple_list_item_1,
|
android.R.layout.simple_list_item_1,
|
||||||
listedPodsList);
|
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) {
|
private void showPodConfirmationDialog(final String selectedPod) {
|
||||||
// Make a clickable link
|
// Make a clickable link
|
||||||
final SpannableString dialogMessage = new SpannableString(getString(R.string.confirm_pod, selectedPod));
|
final SpannableString dialogMessage = new SpannableString(getString(R.string.confirm_pod, selectedPod));
|
||||||
Linkify.addLinks(dialogMessage, Linkify.ALL);
|
Linkify.addLinks(dialogMessage, Linkify.ALL);
|
||||||
|
|
||||||
// Check if online
|
// Check if online
|
||||||
if (!WebHelper.isOnline(PodSelectionActivity.this)) {
|
if (!WebHelper.isOnline(getContext())) {
|
||||||
Snackbar.make(listPods, R.string.no_internet, Snackbar.LENGTH_LONG).show();
|
Snackbar.make(listPods, R.string.no_internet, Snackbar.LENGTH_LONG).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show dialog
|
// Show dialog
|
||||||
new AlertDialog.Builder(PodSelectionActivity.this)
|
new AlertDialog.Builder(getContext())
|
||||||
.setTitle(getString(R.string.confirmation))
|
.setTitle(getString(R.string.confirmation))
|
||||||
.setMessage(dialogMessage)
|
.setMessage(dialogMessage)
|
||||||
.setPositiveButton(android.R.string.yes,
|
.setPositiveButton(android.R.string.yes,
|
||||||
|
@ -201,40 +208,28 @@ public class PodSelectionActivity extends AppCompatActivity {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
Helpers.animateToActivity(this, MainActivity.class, true);
|
((MainActivity)getActivity()).openDiasporaUrl(new DiasporaUrlHelper(appSettings).getPodUrl());
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
public void onDestroy() {
|
||||||
LocalBroadcastManager.getInstance(this).unregisterReceiver(podListReceiver);
|
LocalBroadcastManager.getInstance(getContext()).unregisterReceiver(podListReceiver);
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
getMenuInflater().inflate(R.menu.podselection__menu, menu);
|
inflater.inflate(R.menu.podselection__menu, menu);
|
||||||
return true;
|
super.onCreateOptionsMenu(menu, inflater);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.action_reload: {
|
case R.id.action_reload: {
|
||||||
if (WebHelper.isOnline(PodSelectionActivity.this)) {
|
if (WebHelper.isOnline(getContext())) {
|
||||||
Intent i = new Intent(PodSelectionActivity.this, GetPodsService.class);
|
Intent i = new Intent(getContext(), GetPodsService.class);
|
||||||
startService(i);
|
getContext().startService(i);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
Snackbar.make(listPods, R.string.no_internet, Snackbar.LENGTH_LONG).show();
|
Snackbar.make(listPods, R.string.no_internet, Snackbar.LENGTH_LONG).show();
|
|
@ -1,88 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:fitsSystemWindows="true"
|
|
||||||
tools:context=".activity.PodSelectionActivity">
|
|
||||||
|
|
||||||
<android.support.design.widget.AppBarLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:theme="@style/AppTheme.AppBarOverlay">
|
|
||||||
|
|
||||||
<android.support.v7.widget.Toolbar
|
|
||||||
android:id="@+id/main__topbar"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="?attr/actionBarSize"
|
|
||||||
android:background="?attr/colorPrimary"
|
|
||||||
app:popupTheme="@style/AppTheme.PopupOverlay" />
|
|
||||||
|
|
||||||
</android.support.design.widget.AppBarLayout>
|
|
||||||
|
|
||||||
<RelativeLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
|
||||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
|
||||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
|
||||||
android:paddingTop="@dimen/activity_vertical_margin"
|
|
||||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
|
||||||
tools:showIn="@layout/podselection__activity">
|
|
||||||
|
|
||||||
<ListView
|
|
||||||
android:id="@+id/podselection__listpods"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_above="@+id/podselection__podupti_notice"
|
|
||||||
android:layout_below="@+id/podselection__edit_filter"
|
|
||||||
android:choiceMode="singleChoice" />
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/podselection__edit_filter"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignParentTop="true"
|
|
||||||
android:layout_toEndOf="@+id/textView"
|
|
||||||
android:layout_toStartOf="@+id/podselection__button_select_pod"
|
|
||||||
android:hint="@string/filter_hint"
|
|
||||||
android:inputType="textUri|textWebEditText" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/podselection__button_select_pod"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_above="@+id/podselection__listpods"
|
|
||||||
android:layout_alignEnd="@+id/podselection__listpods"
|
|
||||||
android:layout_alignTop="@+id/podselection__edit_filter"
|
|
||||||
android:contentDescription="@string/confirm_url"
|
|
||||||
android:paddingLeft="5dp"
|
|
||||||
android:paddingRight="5dp"
|
|
||||||
android:src="@drawable/ic_arrow_forward_black_48px" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/podselection__podupti_notice"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignParentBottom="true"
|
|
||||||
android:layout_alignParentStart="true"
|
|
||||||
android:autoLink="web"
|
|
||||||
android:text="@string/podlist_source_note"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/textView"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_above="@+id/podselection__listpods"
|
|
||||||
android:layout_alignParentStart="true"
|
|
||||||
android:layout_alignParentTop="true"
|
|
||||||
android:layout_marginEnd="0dp"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:text="@string/prefix_https"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
|
||||||
|
|
||||||
</RelativeLayout>
|
|
||||||
|
|
||||||
</android.support.design.widget.CoordinatorLayout>
|
|
65
app/src/main/res/layout/podselection__fragment.xml
Normal file
65
app/src/main/res/layout/podselection__fragment.xml
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||||
|
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingTop="@dimen/activity_vertical_margin"
|
||||||
|
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||||
|
tools:showIn="@layout/podselection__fragment">
|
||||||
|
|
||||||
|
<ListView
|
||||||
|
android:id="@+id/podselection__listpods"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_above="@+id/podselection__podupti_notice"
|
||||||
|
android:layout_below="@+id/podselection__edit_filter"
|
||||||
|
android:choiceMode="singleChoice" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/podselection__edit_filter"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
|
android:layout_toEndOf="@+id/textView"
|
||||||
|
android:layout_toStartOf="@+id/podselection__button_select_pod"
|
||||||
|
android:hint="@string/filter_hint"
|
||||||
|
android:inputType="textUri|textWebEditText" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/podselection__button_select_pod"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_above="@+id/podselection__listpods"
|
||||||
|
android:layout_alignEnd="@+id/podselection__listpods"
|
||||||
|
android:layout_alignTop="@+id/podselection__edit_filter"
|
||||||
|
android:contentDescription="@string/confirm_url"
|
||||||
|
android:paddingLeft="5dp"
|
||||||
|
android:paddingRight="5dp"
|
||||||
|
android:src="@drawable/ic_arrow_forward_black_48px" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/podselection__podupti_notice"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_alignParentStart="true"
|
||||||
|
android:autoLink="web"
|
||||||
|
android:text="@string/podlist_source_note"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_above="@+id/podselection__listpods"
|
||||||
|
android:layout_alignParentStart="true"
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
|
android:layout_marginEnd="0dp"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:text="@string/prefix_https"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||||
|
</RelativeLayout>
|
|
@ -1,7 +1,5 @@
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
tools:context=".activity.PodSelectionActivity">
|
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_reload"
|
android:id="@+id/action_reload"
|
||||||
|
|
Loading…
Reference in a new issue