Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use ro.ttf font everywhere #154

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@
<activity
android:name="com.digitalvotingpass.electionchoice.ElectionChoiceActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden">
<meta-data
android:windowSoftInputMode="stateHidden"
android:label="@string/election_choice" >
<meta-data
android:name="android.app.searchable"
android:resource="@xml/searchable">
</meta-data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import com.digitalvotingpass.utilities.MultiChainAddressGenerator;
import com.digitalvotingpass.utilities.Util;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.Service;

import org.bitcoinj.core.Address;
import org.bitcoinj.core.Asset;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package com.digitalvotingpass.blockchain;

import android.util.Log;

import org.bitcoinj.core.Peer;
import org.bitcoinj.core.listeners.DownloadProgressTracker;

import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import com.digitalvotingpass.ocrscanner.Mrz;
import com.digitalvotingpass.ocrscanner.TesseractOCR;
import com.digitalvotingpass.utilities.ErrorDialog;
import com.digitalvotingpass.utilities.Util;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -218,7 +219,7 @@ public void onClick(View v) {
});

infoText = (TextView) view.findViewById(R.id.info_text);
Typeface typeFace= Typeface.createFromAsset(getActivity().getAssets(), "fonts/ro.ttf");
Typeface typeFace = Util.getMainFont(getActivity().getAssets());
infoText.setTypeface(typeFace);
manualInput.setTypeface(typeFace);
controlPanel = view.findViewById(R.id.control);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,23 @@
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Typeface;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.digitalvotingpass.camera.CameraActivity;
import com.digitalvotingpass.electionchoice.Election;
import com.digitalvotingpass.electionchoice.ElectionChoiceActivity;
import com.digitalvotingpass.passportconnection.PassportConActivity;
import com.digitalvotingpass.utilities.CustomTypefaceSpan;
import com.digitalvotingpass.utilities.Util;
import com.google.gson.Gson;

Expand All @@ -26,6 +31,7 @@ public class MainActivity extends AppCompatActivity {

private Button manualInput;
private Button startOCR;
private Typeface typeFace;

public static final int GET_DOC_INFO = 1;
public static final int CHOOSE_ELECTION = 2;
Expand All @@ -36,12 +42,6 @@ protected void onCreate(Bundle savedInstanceState) {
final MainActivity thisActivity = this;

setContentView(R.layout.activity_main);
Toolbar appBar = (Toolbar) findViewById(R.id.app_bar);
setSupportActionBar(appBar);
Util.setupAppBar(appBar, this);

// set the text of the appbar to the selected election
setElectionInAppBar();

manualInput = (Button) findViewById(R.id.manual_input_button);
manualInput.setOnClickListener(new View.OnClickListener() {
Expand All @@ -61,6 +61,20 @@ public void onClick(View v) {
startActivityForResult(intent, GET_DOC_INFO);
}
});
typeFace = Util.getMainFont(getAssets());
manualInput.setTypeface(typeFace);
startOCR.setTypeface(typeFace);
((TextView)findViewById(R.id.divider)).setTypeface(typeFace);
}

@Override
protected void onResume() {
super.onResume();
Toolbar appBar = (Toolbar) findViewById(R.id.app_bar);
setSupportActionBar(appBar);
Util.setupAppBar(appBar, this);
// set the text of the appbar to the selected election
setElectionInAppBar();
}

/**
Expand Down Expand Up @@ -95,7 +109,6 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// Check if we got documentdata and set the documentData attribute
if(requestCode == GET_DOC_INFO && resultCode == RESULT_OK) {

documentData = (DocumentData) data.getExtras().get(DocumentData.identifier);
Intent intent = new Intent(this, PassportConActivity.class);
intent.putExtra(DocumentData.identifier, documentData);
Expand All @@ -118,8 +131,13 @@ public void setElectionInAppBar() {
election = gson.fromJson(json, Election.class);

if(election != null && getSupportActionBar() != null) {
getSupportActionBar().setTitle(election.getKind());
getSupportActionBar().setSubtitle(election.getPlace());
SpannableStringBuilder title = new SpannableStringBuilder(election.getKind());
title.setSpan (new CustomTypefaceSpan("", typeFace), 0, title.length(), Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
SpannableStringBuilder subtitle = new SpannableStringBuilder(election.getPlace());
subtitle.setSpan (new CustomTypefaceSpan("", typeFace), 0, subtitle.length(), Spanned.SPAN_EXCLUSIVE_INCLUSIVE);

getSupportActionBar().setTitle(title);
getSupportActionBar().setSubtitle(subtitle);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package com.digitalvotingpass.digitalvotingpass;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.ArrayAdapter;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
Expand Down Expand Up @@ -39,11 +42,8 @@ public class ManualInputActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_manual_input);
Toolbar appBar = (Toolbar) findViewById(R.id.app_bar);
setSupportActionBar(appBar);
Util.setupAppBar(appBar, this);
Typeface typeFace= Typeface.createFromAsset(getAssets(), "fonts/ro.ttf");

Typeface typeFace= Typeface.createFromAsset(getAssets(), "fonts/ro.ttf");
docNumber = (EditText) findViewById(R.id.doc_num);
docNumber.setTypeface(typeFace);
TextView docNumTitle = (TextView) findViewById(R.id.doc_num_title);
Expand All @@ -54,6 +54,7 @@ protected void onCreate(Bundle savedInstanceState) {
expDateTitle.setTypeface(typeFace);

Button submitBut = (Button) findViewById(R.id.submit_button);
submitBut.setTypeface(typeFace);
submitBut.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Expand All @@ -74,6 +75,14 @@ public void onClick(View view) {
}
}

@Override
protected void onResume() {
super.onResume();
Toolbar appBar = (Toolbar) findViewById(R.id.app_bar);
setSupportActionBar(appBar);
Util.setupAppBar(appBar, this);
}

private void setupExpirySpinners() {
expiryDaySpinner = (Spinner) findViewById(R.id.expiry_day_spinner);
expiryMonthSpinner = (Spinner) findViewById(R.id.expiry_month_spinner);
Expand All @@ -85,13 +94,14 @@ private void setupExpirySpinners() {
}

// Leave the default view (android.R.layout.simple_spinner_item) but set custom view for dropdown to add extra padding
ArrayAdapter<String> dayAdapter = new ArrayAdapter<>(this,
ArrayAdapter<String> dayAdapter = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, days);

dayAdapter.setDropDownViewResource(R.layout.spinner_dropdown);
expiryDaySpinner.setAdapter(dayAdapter);

ArrayAdapter<CharSequence> monthAdapter = ArrayAdapter.createFromResource(this,
R.array.months_array, android.R.layout.simple_spinner_item);
final CharSequence[] strings = getApplicationContext().getResources().getTextArray(R.array.months_array);
ArrayAdapter<CharSequence> monthAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, strings);
monthAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
expiryMonthSpinner.setAdapter(monthAdapter);

Expand Down Expand Up @@ -120,8 +130,8 @@ private void setupDOBSpinners () {
dayAdapter.setDropDownViewResource(R.layout.spinner_dropdown);
dobDaySpinner.setAdapter(dayAdapter);

ArrayAdapter<CharSequence> monthAdapter = ArrayAdapter.createFromResource(this,
R.array.months_array, android.R.layout.simple_spinner_item);
final CharSequence[] strings = getApplicationContext().getResources().getTextArray(R.array.months_array);
ArrayAdapter<CharSequence> monthAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, strings);
monthAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
dobMonthSpinner.setAdapter(monthAdapter);

Expand Down Expand Up @@ -194,4 +204,30 @@ public boolean verifyInput() {
return valid;
}

private class ArrayAdapter<T> extends android.widget.ArrayAdapter<T> {

Typeface typeFace;

public ArrayAdapter(@NonNull Context context, @LayoutRes int resource, @NonNull T[] objects) {
super(context, resource, objects);
typeFace = Util.getMainFont(getAssets());
}

public ArrayAdapter(@NonNull Context context, @LayoutRes int resource, @NonNull List objects) {
super(context, resource, objects);
typeFace = Util.getMainFont(getAssets());
}

public View getView(int position, View convertView, ViewGroup parent) {
View v = super.getView(position, convertView, parent);
((TextView) v).setTypeface(typeFace);
return v;
}

public View getDropDownView(int position, View convertView, ViewGroup parent) {
View v =super.getDropDownView(position, convertView, parent);
((TextView) v).setTypeface(typeFace);
return v;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Typeface;
import android.os.Bundle;
import android.support.design.widget.CoordinatorLayout;
import android.support.v7.app.AppCompatActivity;
Expand Down Expand Up @@ -38,6 +39,7 @@ public class ResultActivity extends AppCompatActivity {
private Button butTransactionHistory;
private Button butProceed;
private MenuItem cancelAction;
private Typeface typeFace;

private int authorizationState = 1;
private final int FAILED = 0;
Expand Down Expand Up @@ -89,15 +91,19 @@ protected void onCreate(Bundle savedInstanceState) {
signedTransactions = (ArrayList<byte[]>) extras.get("signedTransactions");

setContentView(R.layout.activity_result);
Toolbar appBar = (Toolbar) findViewById(R.id.app_bar);
setSupportActionBar(appBar);
Util.setupAppBar(appBar, this);
textVoterName = (TextView) findViewById(R.id.voter_name);
textVotingPassAmount = (TextView) findViewById(R.id.voting_pass_amount);
textVotingPasses = (TextView) findViewById(R.id.voting_passes);
butTransactionHistory = (Button) findViewById(R.id.transactionHistory);
butProceed = (Button) findViewById(R.id.proceed);

typeFace = Util.getMainFont(getAssets());
textVoterName.setTypeface(typeFace);
textVotingPassAmount.setTypeface(typeFace);
textVotingPasses.setTypeface(typeFace);
butTransactionHistory.setTypeface(typeFace);
butProceed.setTypeface(typeFace);

butTransactionHistory.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand All @@ -115,6 +121,15 @@ public void onClick(View v) {
});
}

@Override
protected void onResume() {
super.onResume();
Toolbar appBar = (Toolbar) findViewById(R.id.app_bar);
setSupportActionBar(appBar);
Util.setupAppBar(appBar, this);
// set the text of the appbar to the selected election
}

/**
* Set the result_menu setup to the app bar.
*/
Expand Down Expand Up @@ -149,6 +164,7 @@ private void showSnack(CharSequence text, int backgroundColor, int textColor) {
TextView textView = (TextView) snackbarView.findViewById(com.androidadvance.topsnackbar.R.id.snackbar_text);
textView.setTextColor(getResources().getColor(textColor));
textView.setGravity(Gravity.CENTER_HORIZONTAL);
textView.setTypeface(typeFace);

snack.show();

Expand Down
Loading