force it into landscape mode for now until I can fix tunnel display in portrait mode
This commit is contained in:
@ -1,9 +1,11 @@
|
||||
package net.i2p.android;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.os.Bundle;
|
||||
//import android.support.v4.app.Fragment;
|
||||
import androidx.fragment.app.Fragment;
|
||||
@ -57,6 +59,7 @@ public class I2PActivity extends I2PActivityBase implements
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||
setContentView(R.layout.activity_viewpager);
|
||||
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.main_toolbar);
|
||||
|
@ -8,6 +8,8 @@ import androidx.core.util.Pair;
|
||||
import androidx.core.view.ViewCompat;
|
||||
//import android.support.v7.widget.RecyclerView;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@ -73,6 +75,7 @@ public class TunnelEntryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
|
||||
|
||||
public void setTunnels(List<TunnelEntry> tunnels) {
|
||||
mTunnels = tunnels;
|
||||
Log.d("TunnelEntryAdapter", "setTunnels: size=" + (tunnels != null ? tunnels.size() : "null"));
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@ -148,6 +151,8 @@ public class TunnelEntryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
|
||||
// Replace the contents of a view (invoked by the layout manager)
|
||||
@Override
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
|
||||
Log.d("TunnelEntryAdapter", "onBindViewHolder: position=" + position +
|
||||
" viewType=" + holder.getItemViewType());
|
||||
switch (holder.getItemViewType()) {
|
||||
case R.string.router_not_running:
|
||||
((TextView) holder.itemView).setText(
|
||||
@ -225,9 +230,11 @@ public class TunnelEntryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
|
||||
// Return the size of the dataset (invoked by the layout manager)
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
if (mTunnels == null || mTunnels.isEmpty())
|
||||
if (mTunnels == null || mTunnels.isEmpty()) {
|
||||
Log.d("TunnelEntryAdapter", "getItemCount: returning 1 for empty/null state");
|
||||
return 1;
|
||||
|
||||
}
|
||||
Log.d("TunnelEntryAdapter", "getItemCount: returning " + mTunnels.size());
|
||||
return mTunnels.size();
|
||||
}
|
||||
}
|
||||
|
@ -120,9 +120,10 @@ public class TunnelListFragment extends Fragment implements
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
mClientTunnels = getArguments().getBoolean(SHOW_CLIENT_TUNNELS);
|
||||
//mClientTunnels = getArguments().getBoolean(SHOW_CLIENT_TUNNELS);
|
||||
mClientTunnels = true;
|
||||
|
||||
mRecyclerView.setHasFixedSize(true);
|
||||
//mRecyclerView.setHasFixedSize(true);
|
||||
mRecyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST));
|
||||
|
||||
// use a linear layout manager
|
||||
|
@ -134,6 +134,10 @@ public class TunnelsContainer extends Fragment implements
|
||||
// Initialize ViewPager and adapter
|
||||
mFragPagerAdapter = new TunnelsPagerAdapter(getChildFragmentManager());
|
||||
mViewPager.setAdapter(mFragPagerAdapter);
|
||||
// Make sure the ViewPager has proper height
|
||||
/*mViewPager.setLayoutParams(new ViewGroup.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.MATCH_PARENT));*/
|
||||
|
||||
setupMagicIndicator();
|
||||
|
||||
@ -301,19 +305,19 @@ public class TunnelsContainer extends Fragment implements
|
||||
.replace(R.id.detail_fragment, detailFrag)
|
||||
.commitNow(); // Use commitNow() to execute synchronously
|
||||
} catch (Exception e) {
|
||||
// This exception might occur if the fragment transaction fails due to an invalid state.
|
||||
// It is handled by logging the error to help with debugging.
|
||||
Log.e("TunnelsContainer", "Failed to update detail fragment", e);
|
||||
}
|
||||
} else {
|
||||
// In single-pane mode, simply start the detail activity
|
||||
// for the selected item ID.
|
||||
Intent detailIntent = new Intent(getActivity(), TunnelDetailActivity.class);
|
||||
detailIntent.putExtra(TunnelDetailFragment.TUNNEL_ID, tunnelId);
|
||||
|
||||
ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(
|
||||
getActivity(), pairs);
|
||||
ActivityCompat.startActivity(getActivity(), detailIntent, options.toBundle());
|
||||
ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity(), pairs);
|
||||
detailIntent.putExtra("tunnel_id", tunnelId);
|
||||
ActivityCompat.startActivity(getActivity().getApplicationContext(), detailIntent, options.toBundle());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TunnelDetailFragment.TunnelDetailListener
|
||||
|
||||
|
@ -1,9 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="?android:attr/listPreferredItemHeight">
|
||||
|
||||
<RelativeLayout style="@style/ListItem.TwoLines">
|
||||
<RelativeLayout
|
||||
style="@style/ListItem.TwoLines"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<!-- Tunnel status -->
|
||||
<ImageView
|
||||
@ -55,5 +59,7 @@
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/selectableItemBackground" />
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:focusable="true" />
|
||||
</FrameLayout>
|
||||
|
Reference in New Issue
Block a user