Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed SlideTabs and ViewPager. Modified and cleaned up the code.
- Loading branch information
rn.shruthi@gmail.com
authored and
rn.shruthi@gmail.com
committed
Sep 24, 2015
1 parent
9cdf41a
commit 7a895f8
Showing
12 changed files
with
251 additions
and
920 deletions.
There are no files selected for viewing
142 changes: 92 additions & 50 deletions
142
src/main/java/com/contactshare/activities/MainActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,113 @@ | ||
package com.contactshare.activities; | ||
|
||
import android.content.Context; | ||
import android.os.Bundle; | ||
import android.support.v4.view.ViewPager; | ||
import android.support.v7.app.ActionBarActivity; | ||
import android.view.Menu; | ||
import android.view.MenuItem; | ||
import android.widget.Toolbar; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.EditText; | ||
import android.widget.ImageButton; | ||
import android.widget.ImageView; | ||
import android.widget.TextView; | ||
|
||
import com.contactshare.R; | ||
import com.contactshare.slidetabs.SlidingTabLayout; | ||
import com.contactshare.slidetabs.ViewPagerAdapter; | ||
import com.contactshare.utilities.Constants; | ||
import com.contactshare.utilities.Utilities; | ||
|
||
|
||
public class MainActivity extends ActionBarActivity { | ||
Toolbar toolbar; | ||
ViewPager pager; | ||
ViewPagerAdapter adapter; | ||
SlidingTabLayout tabs; | ||
CharSequence Titles[] = {"Scan", "Make"}; | ||
private int numOfTabs = 2; | ||
public class MainActivity extends ActionBarActivity implements View.OnClickListener { | ||
|
||
static final String ACTION_SCAN = "com.google.zxing.client.android.SCAN"; | ||
private Context ctx; | ||
private TextView txtConDetailHead; | ||
private EditText edtConName; | ||
private EditText edtConNumber; | ||
private EditText edtConEmail; | ||
private Button btnConSave; | ||
private ImageView imgConQrCode; | ||
private ImageView imgQrCode; | ||
private ImageButton btnConEdit; | ||
private ImageButton btnConScan; | ||
private View lytContactDetail; | ||
private View lytQrCode; | ||
|
||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
getActionBar().hide(); | ||
// Creating The ViewPagerAdapter and Passing Fragment Manager, Titles fot the Tabs and Number Of Tabs. | ||
adapter = new ViewPagerAdapter(getSupportFragmentManager(), Titles, numOfTabs); | ||
|
||
// Assigning ViewPager View and setting the adapter | ||
pager = (ViewPager) findViewById(R.id.pager); | ||
pager.setAdapter(adapter); | ||
|
||
// Assiging the Sliding Tab Layout View | ||
tabs = (SlidingTabLayout) findViewById(R.id.tabs); | ||
tabs.setDistributeEvenly(true); // To make the Tabs Fixed set this true, This makes the tabs Space Evenly in Available width | ||
|
||
// Setting Custom Color for the Scroll bar indicator of the Tab View | ||
tabs.setCustomTabColorizer(new SlidingTabLayout.TabColorizer() { | ||
@Override | ||
public int getIndicatorColor(int position) { | ||
return getResources().getColor(R.color.tabsScrollColor); | ||
} | ||
}); | ||
// Setting the ViewPager For the SlidingTabsLayout | ||
tabs.setViewPager(pager); | ||
ctx = getApplicationContext(); | ||
initUI(); | ||
setOnClickListeners(); | ||
|
||
|
||
//Check if there is stored data | ||
if (Utilities.isInitialSetupDone(ctx)) { | ||
lytContactDetail.setVisibility(View.GONE); | ||
lytQrCode.setVisibility(View.VISIBLE); | ||
String sharedName = Utilities.getValueForKeyFromPref(ctx, Constants.KEY_NAME); | ||
String sharedNumber = Utilities.getValueForKeyFromPref(ctx, Constants.KEY_NUMBER); | ||
String sharedEmail = Utilities.getValueForKeyFromPref(ctx, Constants.KEY_EMAIL); | ||
String contact = "Name:" + sharedName + "No:" + sharedNumber + "Email:" + sharedEmail; | ||
imgQrCode.setImageBitmap(Utilities.encodeToQrCode(contact, 500, 500)); | ||
} | ||
|
||
//Saving contact info | ||
/*Intent intent = new Intent(ACTION_SCAN); | ||
intent.putExtra("SCAN_MODE", "QR_CODE_MODE"); | ||
startActivityForResult(intent, 0);*/ | ||
|
||
/* IntentIntegrator integrator = new IntentIntegrator(getActivity()); | ||
integrator.initiateScan();*/ | ||
|
||
|
||
} | ||
|
||
@Override | ||
public boolean onCreateOptionsMenu(Menu menu) { | ||
// Inflate the menu; this adds items to the action bar if it is present. | ||
getMenuInflater().inflate(R.menu.menu_main, menu); | ||
return true; | ||
private void setOnClickListeners() { | ||
btnConSave.setOnClickListener(this); | ||
btnConEdit.setOnClickListener(this); | ||
} | ||
|
||
private void initUI() { | ||
lytContactDetail = findViewById(R.id.lyt_contact_detail); | ||
lytQrCode = findViewById(R.id.lyt_qr_code); | ||
txtConDetailHead = (TextView) findViewById(R.id.txt_con_head); | ||
edtConName = (EditText) findViewById(R.id.edt_con_name); | ||
edtConNumber = (EditText) findViewById(R.id.edt_con_number); | ||
edtConEmail = (EditText) findViewById(R.id.edt_con_email); | ||
btnConSave = (Button) findViewById(R.id.btn_con_save); | ||
imgConQrCode = (ImageView) findViewById(R.id.img_con_qr_code); | ||
btnConEdit = (ImageButton) findViewById(R.id.btn_con_edit); | ||
btnConScan = (ImageButton) findViewById(R.id.btn_con_scan); | ||
//QR code on display mode | ||
imgQrCode = (ImageView) findViewById(R.id.img_qr_code); | ||
lytQrCode.setVisibility(View.GONE); | ||
|
||
} | ||
|
||
@Override | ||
public boolean onOptionsItemSelected(MenuItem item) { | ||
// Handle action bar item clicks here. The action bar will | ||
// automatically handle clicks on the Home/Up button, so long | ||
// as you specify a parent activity in AndroidManifest.xml. | ||
int id = item.getItemId(); | ||
|
||
//noinspection SimplifiableIfStatement | ||
if (id == R.id.action_settings) { | ||
return true; | ||
public void onClick(View v) { | ||
int id = v.getId(); | ||
switch (id) { | ||
case R.id.btn_con_save: | ||
String name = edtConName.getText().toString(); | ||
String number = edtConNumber.getText().toString(); | ||
String email = edtConEmail.getText().toString(); | ||
String contact = "Name:" + name + "No:" + number + "Email:" + email; | ||
imgConQrCode.setImageBitmap(Utilities.encodeToQrCode(contact, 500, 500)); | ||
Utilities.putValueIntoSharedPref(ctx, Constants.KEY_NAME, name); | ||
Utilities.putValueIntoSharedPref(ctx, Constants.KEY_EMAIL, email); | ||
Utilities.putValueIntoSharedPref(ctx, Constants.KEY_NUMBER, number); | ||
break; | ||
case R.id.btn_con_edit: | ||
lytQrCode.setVisibility(View.GONE); | ||
lytContactDetail.setVisibility(View.VISIBLE); | ||
edtConName.setText(Utilities.getValueForKeyFromPref(ctx, Constants.KEY_NAME)); | ||
edtConNumber.setText(Utilities.getValueForKeyFromPref(ctx, Constants.KEY_NUMBER)); | ||
edtConEmail.setText(Utilities.getValueForKeyFromPref(ctx, Constants.KEY_EMAIL)); | ||
break; | ||
} | ||
|
||
return super.onOptionsItemSelected(item); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.