Новые ассеты, диалог выглядит в стиле приложения
This commit is contained in:
@@ -61,6 +61,7 @@ import android.app.DialogFragment;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.AlertDialog.Builder;
|
||||
import android.content.DialogInterface;
|
||||
import android.view.LayoutInflater;
|
||||
import com.dinect.checker.R;
|
||||
|
||||
public class CameraActivity extends AppCompatActivity implements SurfaceHolder.Callback {
|
||||
@@ -75,6 +76,7 @@ public class CameraActivity extends AppCompatActivity implements SurfaceHolder.C
|
||||
private Handler autoFocusHandler;
|
||||
private int mOffset;
|
||||
private String mToken;
|
||||
private LogoutDialogFragment mDialog;
|
||||
|
||||
static {
|
||||
System.loadLibrary("iconv");
|
||||
@@ -221,12 +223,14 @@ public class CameraActivity extends AppCompatActivity implements SurfaceHolder.C
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
|
||||
if (item.getItemId() == R.id.logout) {
|
||||
LogoutDialogFragment newFragment = new LogoutDialogFragment();
|
||||
newFragment.show(getFragmentManager(), "logout");
|
||||
mDialog = new LogoutDialogFragment();
|
||||
mDialog.show(getFragmentManager(), "logout");
|
||||
return true;
|
||||
} else if (item.getItemId() == R.id.faq) {
|
||||
Intent intent = new Intent();
|
||||
@@ -329,7 +333,6 @@ public class CameraActivity extends AppCompatActivity implements SurfaceHolder.C
|
||||
|
||||
AutoFocusCallback autoFocusCallback = new AutoFocusCallback() {
|
||||
public void onAutoFocus(boolean success, Camera camera) {
|
||||
Log.d("kifio", String.valueOf(success));
|
||||
autoFocusHandler.postDelayed(doAutoFocus, 1000);
|
||||
}
|
||||
};
|
||||
@@ -338,7 +341,7 @@ public class CameraActivity extends AppCompatActivity implements SurfaceHolder.C
|
||||
|
||||
private CameraActivity mActivity;
|
||||
private String mCode = "";
|
||||
private String mUrl = "http://pos-api-autoclub.dinect.com/20130701/?auto=";
|
||||
private String mUrl = "https://pos-api-int.dinect.com/20130701/?auto=";
|
||||
private String mCard = "";
|
||||
private String mToken = "";
|
||||
|
||||
@@ -361,7 +364,7 @@ public class CameraActivity extends AppCompatActivity implements SurfaceHolder.C
|
||||
public void run() {
|
||||
|
||||
Request request = new Request.Builder()
|
||||
.addHeader("DM-Authorization", "dmapptoken bdea0f3ba9034b688019a7cac753d1209e2b227f")
|
||||
.addHeader("DM-Authorization", "dmapptoken 9fec83cdca38c357e6b65dbb17514cdd36bf2a08")
|
||||
.addHeader("Authorization", "dmtoken " + mToken)
|
||||
.url(mUrl)
|
||||
.build();
|
||||
@@ -384,28 +387,48 @@ public class CameraActivity extends AppCompatActivity implements SurfaceHolder.C
|
||||
}
|
||||
}
|
||||
|
||||
void dismissDialog() {
|
||||
if (mDialog != null) {
|
||||
mDialog.dismiss();
|
||||
mDialog = null;
|
||||
}
|
||||
}
|
||||
|
||||
void logout() {
|
||||
dismissDialog();
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra("item", "logout");
|
||||
setResult(RESULT_OK, intent);
|
||||
finish();
|
||||
}
|
||||
|
||||
public static class LogoutDialogFragment extends DialogFragment {
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
// Use the Builder class for convenient dialog construction
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
builder.setTitle("Подтверждение");
|
||||
builder.setMessage("Вы действительно хотите выйти и ввести другой номер магазина?")
|
||||
.setPositiveButton("Да", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
dialog.dismiss();
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra("item", "logout");
|
||||
getActivity().setResult(RESULT_OK, intent);
|
||||
getActivity().finish();
|
||||
}
|
||||
})
|
||||
.setNegativeButton("Нет", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
// Create the AlertDialog object and return it
|
||||
LayoutInflater inflater = getActivity().getLayoutInflater();
|
||||
View content = inflater.inflate(R.layout.f_logout_dialog, null);
|
||||
builder.setView(content);
|
||||
View positiveButton = content.findViewById(R.id.positiveButton);
|
||||
View negativeButton = content.findViewById(R.id.negativeButton);
|
||||
|
||||
negativeButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Log.d("kifio", "Negative click!");
|
||||
((CameraActivity) getActivity()).dismissDialog();
|
||||
}
|
||||
});
|
||||
|
||||
positiveButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Log.d("kifio", "Positive click!");
|
||||
((CameraActivity) getActivity()).logout();
|
||||
}
|
||||
});
|
||||
|
||||
return builder.create();
|
||||
}
|
||||
}
|
||||
|
||||
60
android/app/src/main/res/layout/f_logout_dialog.xml
Normal file
60
android/app/src/main/res/layout/f_logout_dialog.xml
Normal file
@@ -0,0 +1,60 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@android:color/white">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical|left"
|
||||
android:textColor="@android:color/black"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginLeft="24dp"
|
||||
android:layout_marginRight="24dp"
|
||||
android:fontFamily="sans-serif-medium"
|
||||
android:textSize="18sp"
|
||||
android:text="@string/logout_title" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginLeft="24dp"
|
||||
android:layout_marginRight="24dp"
|
||||
android:fontFamily="sans-serif-light"
|
||||
android:scaleType="center"
|
||||
android:textSize="18sp"
|
||||
android:textColor="@android:color/black"
|
||||
android:text="@string/logout_text" />
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/positiveButton"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="42dp"
|
||||
android:scaleType="center"
|
||||
android:layout_gravity="right|end"
|
||||
android:fontFamily="sans-serif-medium"
|
||||
android:textColor="#eb0004"
|
||||
android:textSize="14sp"
|
||||
android:text="@string/logout_yes" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/negativeButton"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="42dp"
|
||||
android:layout_marginRight="64dp"
|
||||
android:layout_gravity="right|end"
|
||||
android:fontFamily="sans-serif-medium"
|
||||
android:textColor="#eb0004"
|
||||
android:textSize="14sp"
|
||||
android:text="@string/logout_no" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -4,4 +4,8 @@
|
||||
<string name="scan">Сканировать</string>
|
||||
<string name="faq">FAQ</string>
|
||||
<string name="logout">Выход</string>
|
||||
<string name="logout_title">Подтверждение</string>
|
||||
<string name="logout_text">Вы действительно хотите выйти и ввести другой номер магазина?</string>
|
||||
<string name="logout_yes">Да</string>
|
||||
<string name="logout_no">Нет</string>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user