mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
implement "scan" button
This commit is contained in:
@@ -12,10 +12,10 @@ import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.view.MenuCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentStatePagerAdapter;
|
||||
@@ -42,7 +42,7 @@ import org.thoughtcrime.securesms.util.ViewUtil;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class QrActivity extends BaseActionBarActivity {
|
||||
public class QrActivity extends BaseActionBarActivity implements View.OnClickListener {
|
||||
|
||||
private final static String TAG = QrActivity.class.getSimpleName();
|
||||
private final static int REQUEST_CODE_IMAGE = 46243;
|
||||
@@ -64,7 +64,7 @@ public class QrActivity extends BaseActionBarActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.activity_qr);
|
||||
qrShowFragment = new QrShowFragment();
|
||||
qrShowFragment = new QrShowFragment(this);
|
||||
tabLayout = ViewUtil.findById(this, R.id.tab_layout);
|
||||
viewPager = ViewUtil.findById(this, R.id.pager);
|
||||
ProfilePagerAdapter adapter = new ProfilePagerAdapter(this, getSupportFragmentManager());
|
||||
@@ -216,6 +216,11 @@ public class QrActivity extends BaseActionBarActivity {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
viewPager.setCurrentItem(TAB_SCAN);
|
||||
}
|
||||
|
||||
private class ProfilePagerAdapter extends FragmentStatePagerAdapter {
|
||||
|
||||
private final QrActivity activity;
|
||||
|
||||
@@ -9,6 +9,7 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -46,6 +47,17 @@ public class QrShowFragment extends Fragment implements DcEventCenter.DcEventDel
|
||||
|
||||
private DcContext dcContext;
|
||||
|
||||
private View.OnClickListener scanClicklistener;
|
||||
|
||||
public QrShowFragment() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
public QrShowFragment(View.OnClickListener scanClicklistener) {
|
||||
super();
|
||||
this.scanClicklistener = scanClicklistener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
@@ -87,6 +99,13 @@ public class QrShowFragment extends Fragment implements DcEventCenter.DcEventDel
|
||||
}
|
||||
|
||||
view.findViewById(R.id.share_link_button).setOnClickListener((v) -> shareInviteURL());
|
||||
Button scanBtn = view.findViewById(R.id.scan_qr_button);
|
||||
if (scanClicklistener != null) {
|
||||
scanBtn.setVisibility(View.VISIBLE);
|
||||
scanBtn.setOnClickListener(scanClicklistener);
|
||||
} else {
|
||||
scanBtn.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user