mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-17 11:19:01 +00:00
Fixed styles. Made QR code purple. Encoded url to QR code. Made QR code larger
This commit is contained in:
parent
4904cbc7b9
commit
9762dc3a04
6 changed files with 42 additions and 18 deletions
|
|
@ -45,6 +45,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/CardView.Default"
|
||||
android:id="@+id/qrWrapper"
|
||||
>
|
||||
|
||||
<LinearLayout
|
||||
|
|
|
|||
|
|
@ -8,29 +8,41 @@
|
|||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Have someone invite you with this QR Code"
|
||||
android:text="@string/qr_section_title"
|
||||
style="@style/SectionTitle"
|
||||
android:layout_gravity="center"
|
||||
/>
|
||||
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="200dp"
|
||||
android:layout_height="300dp"
|
||||
android:id="@+id/qrCodeWrapper">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/QRImageView"
|
||||
android:layout_gravity="center_horizontal" />
|
||||
android:layout_gravity="center" />
|
||||
|
||||
<com.habitrpg.android.habitica.ui.AvatarView
|
||||
android:id="@+id/avatarView"
|
||||
android:layout_width="103dp"
|
||||
android:layout_height="90dp"
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_gravity="center"
|
||||
/>
|
||||
android:background="@color/transparent"
|
||||
android:clipChildren="true"
|
||||
android:padding="0dp"
|
||||
>
|
||||
<com.habitrpg.android.habitica.ui.AvatarView
|
||||
android:id="@+id/avatarView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_centerVertical="true"
|
||||
/>
|
||||
</RelativeLayout>
|
||||
</FrameLayout>
|
||||
|
||||
<Button
|
||||
|
|
|
|||
|
|
@ -379,6 +379,7 @@ To start, which parts of your life do you want to improve?</string>
|
|||
<string name="copy_chat_message">Copy to clipboard</string>
|
||||
|
||||
<!-- QR Strings -->
|
||||
<string name="qr_section_title">Have someone invite you with this QR Code</string>
|
||||
<string name="qr_album_name">habitica</string>
|
||||
<string name="qr_file_name"> habitrpg-qr-code.jpg</string>
|
||||
<string name="qr_save_message">QR code saved at </string>
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import android.widget.Toast;
|
|||
import com.habitrpg.android.habitica.R;
|
||||
import com.habitrpg.android.habitica.ui.AvatarView;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.HabitRPGUser;
|
||||
import com.mikepenz.materialize.color.Material;
|
||||
import com.raizlabs.android.dbflow.runtime.transaction.BaseTransaction;
|
||||
import com.raizlabs.android.dbflow.runtime.transaction.TransactionListener;
|
||||
import com.raizlabs.android.dbflow.sql.builder.Condition;
|
||||
|
|
@ -41,6 +42,7 @@ public class QrCodeManager {
|
|||
private String content;
|
||||
private String userId;
|
||||
private Context context;
|
||||
private String qrProfileUrl = "https://habitica.com/qr-code/user/";
|
||||
|
||||
private ImageView qrCodeImageView;
|
||||
private Button qrCodeDownloadButton;
|
||||
|
|
@ -78,7 +80,7 @@ public class QrCodeManager {
|
|||
this.fileName = this.context.getString(R.string.qr_file_name);
|
||||
this.saveMessage = this.context.getString(R.string.qr_save_message);
|
||||
|
||||
this.content = userId;
|
||||
this.content = this.qrProfileUrl + userId;
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
|
|
@ -106,7 +108,7 @@ public class QrCodeManager {
|
|||
return;
|
||||
}
|
||||
|
||||
Bitmap myBitmap = QRCode.from(this.content).withSize(1000, 1000).bitmap();
|
||||
Bitmap myBitmap = QRCode.from(this.content).withColor(0xFF432874, 0xFFFFFFFF).withSize(400, 400).bitmap();
|
||||
qrCodeImageView.setImageBitmap(myBitmap);
|
||||
}
|
||||
|
||||
|
|
@ -130,7 +132,6 @@ public class QrCodeManager {
|
|||
|
||||
try {
|
||||
FileOutputStream outputStream = new FileOutputStream(pathToQRCode);
|
||||
|
||||
qrCodeWrapper.setDrawingCacheEnabled(true);
|
||||
Bitmap b = qrCodeWrapper.getDrawingCache();
|
||||
b.compress(Bitmap.CompressFormat.JPEG, 95, outputStream);
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import com.raizlabs.android.dbflow.sql.language.Select;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.design.widget.TabLayout;
|
||||
import android.support.v4.app.Fragment;
|
||||
|
|
@ -180,12 +181,16 @@ public class PartyInviteActivity extends BaseActivity {
|
|||
|
||||
IntentResult scanningResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
|
||||
|
||||
if (scanningResult != null) {
|
||||
userIdToInvite = scanningResult.getContents();
|
||||
if (scanningResult != null && scanningResult.getContents() != null) {
|
||||
String qrCodeUrl = scanningResult.getContents();
|
||||
Uri uri = Uri.parse(qrCodeUrl);
|
||||
if (uri == null || uri.getPathSegments().size() < 3) {
|
||||
return;
|
||||
}
|
||||
userIdToInvite = uri.getPathSegments().get(2);
|
||||
|
||||
//@TODO: Move to user helper/model
|
||||
new Select().from(HabitRPGUser.class).where(Condition.column("id").eq(hostConfig.getUser())).async().querySingle(userTransactionListener);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -197,7 +202,7 @@ public class PartyInviteActivity extends BaseActivity {
|
|||
}
|
||||
|
||||
Toast toast = Toast.makeText(getApplicationContext(),
|
||||
"Invited: " + userIdToInvite, Toast.LENGTH_SHORT);
|
||||
"Invited: " + userIdToInvite, Toast.LENGTH_LONG);
|
||||
toast.show();
|
||||
|
||||
Map<String, Object> inviteData = new HashMap<>();
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import android.os.Environment;
|
|||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.preference.PreferenceManager;
|
||||
import android.support.v7.widget.CardView;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.Log;
|
||||
|
|
@ -68,6 +69,9 @@ public class GroupInformationFragment extends BaseFragment {
|
|||
@BindView(R.id.qrLayout)
|
||||
LinearLayout qrLayout;
|
||||
|
||||
@BindView(R.id.qrWrapper)
|
||||
CardView qrWrapper;
|
||||
|
||||
private View view;
|
||||
private Group group;
|
||||
private HabitRPGUser user;
|
||||
|
|
@ -121,8 +125,8 @@ public class GroupInformationFragment extends BaseFragment {
|
|||
qrCodeManager.setUpView(qrLayout);
|
||||
}
|
||||
|
||||
if (user.getParty().getId() != null) {
|
||||
((ViewGroup) qrLayout.getParent()).removeView(qrLayout);
|
||||
if (user != null && user.getParty().getId() != null) {
|
||||
((ViewGroup) qrWrapper.getParent()).removeView(qrWrapper);
|
||||
}
|
||||
|
||||
return view;
|
||||
|
|
|
|||
Loading…
Reference in a new issue