Skip to content

Commit

Permalink
Revert "Remove TelEnterActivity"
Browse files Browse the repository at this point in the history
This reverts commit 4a0c21c.
  • Loading branch information
udenr committed Aug 20, 2024
1 parent c9d0004 commit edb0de9
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 8 deletions.
5 changes: 5 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@
android:label="E-Mail"
android:parentActivityName=".ui.activities.generator.QrGeneratorOverviewActivity"
android:windowSoftInputMode="adjustResize" />
<activity
android:name=".ui.activities.generator.TelEnterActivity"
android:label="Phone number"
android:parentActivityName=".ui.activities.generator.QrGeneratorOverviewActivity"
android:windowSoftInputMode="adjustResize" />
<activity
android:name=".ui.activities.generator.UrlEnterActivity"
android:label="URL"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.stream.IntStream;


public class QrGeneratorOverviewActivity extends AppCompatActivity {
Expand Down Expand Up @@ -50,21 +49,15 @@ protected void onCreate(Bundle savedInstanceState) {
R.drawable.ic_person_accent_24dp,
R.drawable.ic_baseline_shopping_cart_24dp};

// Remove phone element (position 3) for Google Play version
String[] finalGenerator = generator;
Integer[] finalIcons = icons;
generator = IntStream.range(0, finalGenerator.length).filter(value -> value != 3).mapToObj(value -> finalGenerator[value]).toList().toArray(String[]::new);
icons = IntStream.range(0, finalIcons.length).filter(value -> value != 3).mapToObj(value -> finalIcons[value]).toList().toArray(Integer[]::new);
GeneratorListAdapter adapter = new GeneratorListAdapter(this, generator, icons);
listView.setAdapter(adapter);

listView.setOnItemClickListener((parent, view, position, id) -> {
// Skip position 3 for Google Play version
if (position >= 3) position++;
Intent intent = switch (position) {
case 0 -> new Intent(QrGeneratorOverviewActivity.this, TextEnterActivity.class);
case 1 -> new Intent(QrGeneratorOverviewActivity.this, MailEnterActivity.class);
case 2 -> new Intent(QrGeneratorOverviewActivity.this, UrlEnterActivity.class);
case 3 -> new Intent(QrGeneratorOverviewActivity.this, TelEnterActivity.class);
case 4 -> new Intent(QrGeneratorOverviewActivity.this, SmsEnterActivity.class);
case 5 -> new Intent(QrGeneratorOverviewActivity.this, GeoLocationEnterActivity.class);
case 6 -> new Intent(QrGeneratorOverviewActivity.this, MeCardEnterActivity.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package com.secuso.privacyfriendlycodescanner.qrscanner.ui.activities.generator;

import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.text.InputFilter;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.widget.ConstraintLayout;

import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton;
import com.secuso.privacyfriendlycodescanner.qrscanner.R;
import com.secuso.privacyfriendlycodescanner.qrscanner.generator.Contents;
import com.secuso.privacyfriendlycodescanner.qrscanner.ui.helpers.GeneratorKeyboardListener;

public class TelEnterActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tel_enter);

final EditText qrResult = (EditText) findViewById(R.id.editPhone);

int maxLength = 75;
qrResult.setFilters(new InputFilter[]{new InputFilter.LengthFilter(maxLength)});

ExtendedFloatingActionButton generate = (ExtendedFloatingActionButton) findViewById(R.id.btnGenerate);

ConstraintLayout rootView = (ConstraintLayout) findViewById(R.id.rootView);
GeneratorKeyboardListener listener = new GeneratorKeyboardListener(rootView, generate, R.id.btnGenerate, getApplicationContext().getResources().getDisplayMetrics().densityDpi);
rootView.getViewTreeObserver().addOnGlobalLayoutListener(listener);

generate.setOnClickListener(new View.OnClickListener() {
String result;

@Override
public void onClick(View v) {
result = qrResult.getText().toString();
if (result.isEmpty()) {
Toast.makeText(TelEnterActivity.this, R.string.activity_enter_toast_missing_data, Toast.LENGTH_SHORT).show();
return;
}
Intent i = new Intent(TelEnterActivity.this, QrGeneratorDisplayActivity.class);
i.putExtra("gn", result);
i.putExtra("type", Contents.Type.PHONE);
startActivity(i);
}

});
}
}

0 comments on commit edb0de9

Please sign in to comment.