Android: package at.inntelco.INNTEL.data; import java.io.Serializable; public class AuthInfo implements Serializable { private static final long serialVersionUID = 74954641L; public String result; public String mobilenumbersyntaxcorrected; public String dialoguuid; } package at.inntelco.INNTEL.data; import java.io.Serializable; import java.util.Date; public class CallEntity implements Serializable { private static final long serialVersionUID = 7493111L; public String id; public User user; public boolean outgoing=false; public boolean success=false; public Date time; public int duration; public CallEntity(String id, User user, boolean outgoing, Date time){ this.id=id; this.user=user; this.outgoing=outgoing; this.time=time; } } package at.inntelco.INNTEL.data; import java.io.Serializable; public class CarrierCi implements Serializable { private static final long serialVersionUID = 74954641L; public String id; public String result; public String contenturl; public String backGround; public String foreGround; public String markColor; public String languageId; public int pullingFrequency; } package at.inntelco.INNTEL.data; import java.io.Serializable; public class Entry implements Serializable { private static final long serialVersionUID = 74954641L; public String translation; public String systemword; } package at.inntelco.INNTEL.data; import java.io.Serializable; public class Language implements Serializable { private static final long serialVersionUID = 74954641L; public String id; public String name; public String shortname; } package at.inntelco.INNTEL.data; import java.io.Serializable; public class LoginInfo implements Serializable { private static final long serialVersionUID = 74954641L; public String userid; public String result; public String apikey; public String authMobileNumber; public String dialoguuid; public String authorizedApiKey; public boolean isAuthenticated = false; } package at.inntelco.INNTEL.data; import java.io.Serializable; import java.util.ArrayList; import at.inntelco.INNTEL.CircleView; import at.inntelco.INNTEL.Utilities; public class User implements Serializable { private static final long serialVersionUID = 749511L; public String id; public String origin = "internal"; public String extension; public String mobile = ""; public String presence = ""; public String firstname = ""; public String lastname = ""; public ArrayList contacts; public String sipUserName; public String blf=""; public String sipPassword; public String sipServer; public String proxyServer; public String transportType; public String userAgentStr; public transient CircleView status; public User findInContactByNormalizedNumber(String normalizedNumber){ User ret = null; User one = null; for(int i=0;i entries; public HashMap index; } package at.inntelco.INNTEL.home; import android.Manifest; import android.content.Context; import android.content.pm.PackageManager; import android.graphics.Color; import android.util.TypedValue; import android.view.Gravity; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.Spinner; import android.widget.TextView; import org.linphone.core.Account; import org.linphone.core.AccountParams; import org.linphone.core.Address; import org.linphone.core.AuthInfo; import org.linphone.core.Core; import org.linphone.core.Factory; import org.linphone.core.TransportType; import java.util.Date; import at.inntelco.INNTEL.BetterActivity; import at.inntelco.INNTEL.BetterImageView; import at.inntelco.INNTEL.BuildConfig; import at.inntelco.INNTEL.CircleView; import at.inntelco.INNTEL.INNTELApplication; import at.inntelco.INNTEL.R; import at.inntelco.INNTEL.data.CallEntity; public class AvatarRow extends LinearLayout { public PackageManager packageManager; public String packageName = ""; public CircleView knoedel; public BetterImageView onlineImage; public Spinner languageSelector; private boolean adjustingDropdown = false; public AvatarRow(Context context, BetterActivity mother){ super(context); packageManager = mother.getPackageManager(); packageName = mother.getPackageName(); this.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); this.setOrientation(LinearLayout.HORIZONTAL); mother.addHorizontalSpacer(this, 8, mother); BetterImageView avatarImage = new BetterImageView(context); LinearLayout.LayoutParams imageParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, mother.global.appleH(60)); avatarImage.setLayoutParams(imageParams); avatarImage.setScaleType(ImageView.ScaleType.CENTER_INSIDE); avatarImage.setAdjustViewBounds(true); String remoteAvatar = mother.global.puller.storedData.carrierCi.contenturl+"carrier/"+ mother.global.puller.storedData.carrierCi.id + "/" + mother.global.puller.storedData.loginInfo.userid + "/avatar.png"; mother.global.puller.loadImage(avatarImage, remoteAvatar, null, mother); addView(avatarImage); mother.addHorizontalSpacer(this, 8, mother); LinearLayout centerText = new LinearLayout(context); centerText.setLayoutParams(new LinearLayout.LayoutParams(mother.global.appleW(253), LinearLayout.LayoutParams.WRAP_CONTENT)); centerText.setOrientation(LinearLayout.VERTICAL); TextView avatarName = new TextView(context); avatarName.setText(mother.global.puller.storedData.user.firstname + " " + mother.global.puller.storedData.user.lastname + " (" + mother.global.puller.storedData.user.extension + ")"); avatarName.setTextSize(TypedValue.COMPLEX_UNIT_PX, mother.global.appleH(22)); avatarName.setTextAlignment(View.TEXT_ALIGNMENT_TEXT_START); avatarName.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); avatarName.setTextColor(Color.parseColor(mother.global.puller.storedData.carrierCi.backGround)); centerText.addView(avatarName); centerText.setBackgroundColor(Color.parseColor(mother.global.puller.storedData.carrierCi.foreGround)); LinearLayout selectorBackground = new LinearLayout(context); selectorBackground.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); selectorBackground.setBackgroundColor(Color.TRANSPARENT); selectorBackground.setOrientation(LinearLayout.HORIZONTAL); selectorBackground.setGravity(Gravity.CENTER); knoedel = new CircleView(context); knoedel.setCircleColor(Color.GREEN); knoedel.setLayoutParams(new LinearLayout.LayoutParams(mother.global.appleW(25), mother.global.appleH(16))); selectorBackground.addView(knoedel); centerText.addView(selectorBackground); languageSelector = new Spinner(context); LinearLayout.LayoutParams pram = new LinearLayout.LayoutParams(mother.global.appleW(160), LinearLayout.LayoutParams.WRAP_CONTENT); pram.setMargins(-mother.global.appleW(4), 0, 0, 0); languageSelector.setLayoutParams(pram); languageSelector.setMinimumWidth(mother.global.appleW(160)); languageSelector.setMinimumHeight(mother.global.appleH(23)); languageSelector.setBackgroundColor(Color.TRANSPARENT); String[] wurst = {mother.global.getTranslation("available"), mother.global.getTranslation("unavailable")}; ArrayAdapter languageAdapter = new ArrayAdapter(context, R.layout.view_spinner_item, wurst); languageAdapter.setDropDownViewResource(R.layout.view_spinner_dropdown_item); languageSelector.setAdapter(languageAdapter); languageSelector.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView parent, View view, int position, long id) { if(!adjustingDropdown) { System.out.println("AvatarRow item selected"); System.out.println(position); if (position == 0) { mother.global.puller.storedData.avatarDropdownSelection = 0; mother.global.puller.saveStoredData(); String username = mother.global.puller.storedData.user.sipUserName; String password = mother.global.puller.storedData.user.sipPassword; String domain = mother.global.puller.storedData.user.sipServer; String theAddress = mother.global.puller.storedData.user.proxyServer; TransportType transportType = TransportType.Udp; if (mother.global.puller.storedData.user.transportType.equals("TLS")) transportType = TransportType.Tls; if (mother.global.puller.storedData.user.transportType.equals("TCP")) transportType = TransportType.Tcp; AuthInfo authInfo = Factory.instance().createAuthInfo(username, null, password, null, null, domain, null); Core core = INNTELApplication.coreContext.core; AccountParams params = core.createAccountParams(); core.setUserAgent(mother.global.puller.storedData.user.userAgentStr, "" + BuildConfig.VERSION_NAME); Address identity = Factory.instance().createAddress("sip:" + username + "@" + domain); params.setIdentityAddress(identity); Address address = Factory.instance().createAddress("sip:" + theAddress);// address.setTransport(transportType); params.setServerAddress(address); params.setRegisterEnabled(true); params.setPushNotificationAllowed(true); Account account = core.createAccount(params); core.addAuthInfo(authInfo); core.addAccount(account); core.setDefaultAccount(account); } else { mother.global.puller.storedData.avatarDropdownSelection = 1; mother.global.puller.saveStoredData(); Core core = INNTELApplication.coreContext.core; Account defAcc = core.getDefaultAccount(); if(defAcc!=null) { AccountParams defParams = defAcc.getParams(); AccountParams clonedParams = defParams.clone(); clonedParams.setRegisterEnabled(false); defAcc.setParams(clonedParams); core.removeAccount(defAcc); } core.clearAccounts(); } } } @Override public void onNothingSelected(AdapterView parent) { } }); languageSelector.setSelection(mother.global.puller.storedData.avatarDropdownSelection); selectorBackground.addView(languageSelector); addView(centerText); mother.addHorizontalSpacer(this, 4, mother); onlineImage = new BetterImageView(context); LinearLayout.LayoutParams onlineImageParams = new LinearLayout.LayoutParams(mother.global.appleW(40), mother.global.appleH(60)); onlineImage.setLayoutParams(onlineImageParams); onlineImage.setScaleType(ImageView.ScaleType.CENTER_INSIDE); onlineImage.setAdjustViewBounds(true); onlineImage.setImageResource(R.drawable.online); View.OnClickListener onlineButListener = new View.OnClickListener() { @Override public void onClick(View v) { System.out.println("onlineButPressed."); if(languageSelector.getSelectedItemPosition()==0) { languageSelector.setSelection(1); } else { languageSelector.setSelection(0); } } }; onlineImage.setOnClickListener(onlineButListener); addView(onlineImage); mother.addHorizontalSpacer(this, 12, mother); adjustingDropdown=false; } public void setSelection(int pos){ languageSelector.setSelection(pos); } public void setDropDownSelectionWithoutAction(int pos){ adjustingDropdown = true; languageSelector.setSelection(pos); adjustingDropdown = false; } } package at.inntelco.INNTEL.home; import android.content.Context; import android.content.Intent; import android.view.MenuItem; import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; import com.google.android.material.bottomnavigation.BottomNavigationView; import at.inntelco.INNTEL.Global; import at.inntelco.INNTEL.R; public class BottomNavigationListener implements BottomNavigationView.OnNavigationItemSelectedListener { public Context context; public Global global; public AppCompatActivity mother; public BottomNavigationListener(Context context, Global global, AppCompatActivity mother) { this.context = context; this.global = global; this.mother = mother; } @Override public boolean onNavigationItemSelected(@NonNull MenuItem item) { global.activeMenuItem = item; Intent newIntent; switch (item.getItemId()) { case R.id.navigation_contacts: newIntent = new Intent(context, Contacts.class); newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); mother.startActivity(newIntent); return true; case R.id.navigation_history: newIntent = new Intent(context, History.class); newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); mother.startActivity(newIntent); return true; case R.id.navigation_dial: newIntent = new Intent(context, Dial.class); newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); mother.startActivity(newIntent); return true; case R.id.navigation_settings: newIntent = new Intent(context, Settings.class); newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); mother.startActivity(newIntent); return true; } return false; } } package at.inntelco.INNTEL.home; import android.annotation.SuppressLint; import android.app.Notification; import android.app.NotificationManager; import android.content.Context; import android.content.Intent; import android.content.res.ColorStateList; import android.graphics.Color; import android.graphics.PorterDuff; import android.os.Bundle; import android.os.Handler; import android.text.InputType; import android.util.TypedValue; import android.view.Gravity; import android.view.KeyEvent; import android.view.View; import android.view.inputmethod.BaseInputConnection; import android.view.inputmethod.InputMethodManager; import android.widget.EditText; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.TextView; import androidx.core.app.NotificationCompat; import com.google.android.material.bottomnavigation.BottomNavigationView; import org.linphone.core.Address; import org.linphone.core.AudioDevice; import org.linphone.core.CallParams; import org.linphone.core.Factory; import org.linphone.core.MediaEncryption; import org.linphone.core.Reason; import org.w3c.dom.Text; import at.inntelco.INNTEL.BetterActivity; import at.inntelco.INNTEL.BetterImageView; import at.inntelco.INNTEL.CircleView; import at.inntelco.INNTEL.LoadingScreen; import at.inntelco.INNTEL.INNTELApplication; import at.inntelco.INNTEL.R; import at.inntelco.INNTEL.Utilities; import at.inntelco.INNTEL.data.CallEntity; public class CallingScreen extends BetterActivity { public TextView headLine; public CircleView theBut; public TextView timeLine; public CallEntity entity = null; public AvatarRow avatarRow; public boolean countdownrunning = false; public boolean hangupchecking = false; private Runnable mCheckForTimePassedRunnable = new Runnable() { @Override public void run() { if(countdownrunning) { secondspassed++; int mins = secondspassed / 60; int secs = secondspassed - (mins * 60); timeLine.setText(mins + ":" + secs); keepOnDoingTime.postDelayed(this, 1000); }else secondspassed = 0; } }; private Runnable mCheckForHangupRunnable = new Runnable() { @Override public void run() { if(hangupchecking) { if (!INNTELApplication.coreContext.callRunning) { partnerDidHangUp(); } keepOnDoingHangupCheck.postDelayed(this, 1000); } } }; public void partnerDidHangUp(){ if (global.puller.storedData.callList.size() > 0) global.puller.storedData.callList.get(global.puller.storedData.callList.size() - 1).duration = secondspassed; global.puller.saveStoredData(); countdownrunning = false; hangupchecking = false; super.onBackPressed(); } public int secondspassed = 0; public Handler keepOnDoingTime; public Handler keepOnDoingHangupCheck; private void checkForLogIn() { if (avatarRow != null){ if (INNTELApplication.coreContext.loggedIn) { avatarRow.knoedel.setCircleColor(Color.GREEN); avatarRow.onlineImage.setImageResource(R.drawable.online); } else { avatarRow.knoedel.setCircleColor(Color.RED); avatarRow.onlineImage.setImageResource(R.drawable.offline); } avatarRow.setDropDownSelectionWithoutAction(global.puller.storedData.avatarDropdownSelection); } } @Override protected void onResume() { super.onResume(); checkForLogIn(); navigation.getMenu().getItem(0).setChecked(false); navigation.getMenu().getItem(1).setChecked(false); navigation.getMenu().getItem(2).setChecked(false); navigation.getMenu().getItem(3).setChecked(false); navigation.getMenu().getItem(0).setEnabled(false); navigation.getMenu().getItem(1).setEnabled(false); navigation.getMenu().getItem(2).setEnabled(false); navigation.getMenu().getItem(3).setEnabled(false); avatarRow.languageSelector.setEnabled(false); avatarRow.onlineImage.setClickable(false); hangupchecking = true; INNTELApplication.coreContext.callRunning = true; if (global.puller.storedData.callEntity.outgoing) { String remoteSipUri = "sip:" + global.puller.storedData.callEntity.user.mobile + "@" + global.puller.storedData.user.sipServer; Address remoteAddress = Factory.instance().createAddress(remoteSipUri); if (remoteAddress == null) System.out.println("Error unparsable remote Address in outgoing call CallingScreen"); CallParams params = INNTELApplication.coreContext.core.createCallParams(null); if (params == null) System.out.println("Error in creating CallParams in outgoing call CallingScreen"); params.setMediaEncryption(MediaEncryption.None); INNTELApplication.coreContext.core.inviteAddressWithParams(remoteAddress, params); } else { if(INNTELApplication.coreContext.core.getCurrentCall()!=null) { INNTELApplication.coreContext.core.getCurrentCall().accept(); if(global.puller.storedData.callList.size()>0) global.puller.storedData.callList.get(global.puller.storedData.callList.size()-1).success=true; global.puller.saveStoredData(); }else{ Intent newIntent = new Intent(this, Contacts.class); newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); startActivity(newIntent); } } } @SuppressLint("MissingSuperCall") @Override public void onBackPressed() { } @Override protected void onCreate(Bundle savedInstanceState) { INNTELApplication application = (INNTELApplication) getApplication(); global = application.global; super.onCreate(savedInstanceState); setStatusBarColorNow(global.puller.storedData.carrierCi.foreGround); setContentView(R.layout.activity_calling); BottomNavigationView.OnNavigationItemSelectedListener listener = new BottomNavigationListener(this, global, this); navigation = (BottomNavigationView) findViewById(R.id.navigation); Utilities.createMenu(navigation, global); ColorStateList iconTintList = ColorStateList.valueOf(Color.parseColor(global.puller.storedData.carrierCi.foreGround)); int[][] states = new int[][]{ new int[]{android.R.attr.state_checked}, // checked new int[]{-android.R.attr.state_checked} // unchecked }; int[] colors = new int[]{ Color.GRAY, // for checked state Color.GRAY // for unchecked state }; ColorStateList colorStateList = new ColorStateList(states, colors); navigation.setItemIconTintList(colorStateList); navigation.setItemTextColor(colorStateList); entity = global.puller.storedData.callEntity; progressDialog = new LoadingScreen(this, global); progressDialog.show(); buildGUI(); } public void buildGUI() { LinearLayout fixedUpperStack = findViewById(R.id.fixedUpperStack); fixedUpperStack.setGravity(Gravity.CENTER); fixedUpperStack.setClipChildren(false); addVerticalSpacer(fixedUpperStack, 8, this); fixedUpperStack.setBackgroundColor(Color.parseColor(global.puller.storedData.carrierCi.foreGround)); avatarRow = new AvatarRow(this, this); fixedUpperStack.addView(avatarRow); addVerticalSpacer(fixedUpperStack, 8, this); LinearLayout fixedLowerStack = findViewById(R.id.fixedLowerStack); fixedLowerStack.setOrientation(LinearLayout.VERTICAL); fixedLowerStack.setHorizontalGravity(Gravity.CENTER); fixedLowerStack.setVerticalGravity(Gravity.CENTER); fixedLowerStack.setBackgroundColor(Color.parseColor(global.puller.storedData.carrierCi.backGround)); addVerticalSpacer(fixedLowerStack, 18, this); headLine = new TextView(this); headLine.setText(global.puller.storedData.callEntity.user.mobile); headLine.setTextSize(TypedValue.COMPLEX_UNIT_PX, global.appleH(32)); headLine.setTextAlignment(View.TEXT_ALIGNMENT_CENTER); headLine.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); headLine.setTextColor(Color.parseColor(global.puller.storedData.carrierCi.foreGround)); headLine.setBackgroundColor(Color.parseColor(global.puller.storedData.carrierCi.backGround)); headLine.setSingleLine(true); fixedLowerStack.addView(headLine); addVerticalSpacer(fixedLowerStack, 18, this); TextView headLineSub = new TextView(this); headLineSub.setText(global.puller.storedData.callEntity.user.lastname); headLineSub.setTextSize(TypedValue.COMPLEX_UNIT_PX, global.appleH(18)); headLineSub.setTextAlignment(View.TEXT_ALIGNMENT_CENTER); headLineSub.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); headLineSub.setTextColor(Color.parseColor(global.puller.storedData.carrierCi.foreGround)); headLineSub.setBackgroundColor(Color.parseColor(global.puller.storedData.carrierCi.backGround)); headLineSub.setSingleLine(true); fixedLowerStack.addView(headLineSub); addVerticalSpacer(fixedLowerStack, 8, this); timeLine = new TextView(this); timeLine.setText("00:00"); timeLine.setTextSize(TypedValue.COMPLEX_UNIT_PX, global.appleH(18)); timeLine.setTextAlignment(View.TEXT_ALIGNMENT_CENTER); timeLine.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); timeLine.setTextColor(Color.parseColor(global.puller.storedData.carrierCi.foreGround)); timeLine.setBackgroundColor(Color.parseColor(global.puller.storedData.carrierCi.backGround)); timeLine.setSingleLine(true); fixedLowerStack.addView(timeLine); addVerticalSpacer(fixedLowerStack, 32, this); int rand = 60; int space = 30; int vspace = 16; LinearLayout firstButRow = new LinearLayout(this); firstButRow.setOrientation(LinearLayout.HORIZONTAL); fixedLowerStack.addView(firstButRow); int circleWidth = (375 - (rand + space + space + rand)) / 3; int thisrand = (375 - (2 * circleWidth) - space) / 2; addHorizontalSpacer(firstButRow, thisrand, this); addTelephoneButton(circleWidth, firstButRow, "mute"); addHorizontalSpacer(firstButRow, space, this); addTelephoneButton(circleWidth, firstButRow, "loud"); addHorizontalSpacer(firstButRow, thisrand, this); addVerticalSpacer(fixedLowerStack, 3 * vspace, this); LinearLayout fifthButRow = new LinearLayout(this); fifthButRow.setOrientation(LinearLayout.HORIZONTAL); fifthButRow.setHorizontalGravity(Gravity.CENTER); fifthButRow.setVerticalGravity(Gravity.CENTER); fixedLowerStack.addView(fifthButRow); addHorizontalSpacer(fifthButRow, rand + circleWidth + space, this); addTelephoneButton(circleWidth, fifthButRow, "hoerer"); addHorizontalSpacer(fifthButRow, rand + circleWidth + space, this); hideLoadingScreenIfNothingLeftToWaitFor(); countdownrunning = true; hangupchecking = true; keepOnDoingTime = new Handler(); keepOnDoingTime.postDelayed(mCheckForTimePassedRunnable, 1000); keepOnDoingHangupCheck = new Handler(); keepOnDoingHangupCheck.postDelayed(mCheckForHangupRunnable,1000); System.out.println("YYYYYYYYYYYYYYYYY buildGUI done"); } public boolean isMute = false; public void toggleMute() { isMute = !isMute; if (isMute) { muteBut.setCircleColor(Color.parseColor(global.puller.storedData.carrierCi.foreGround)); muteImage.setBackgroundColor(Color.WHITE); muteImage.setColorFilter(Color.parseColor(global.puller.storedData.carrierCi.foreGround), PorterDuff.Mode.SRC_IN); INNTELApplication.coreContext.core.setMicEnabled(false); } else { muteBut.setCircleColor(Color.WHITE); muteImage.setBackgroundColor(Color.parseColor(global.puller.storedData.carrierCi.foreGround)); muteImage.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_IN); INNTELApplication.coreContext.core.setMicEnabled(true); } } public boolean isLoud = false; public AudioDevice.Type originalType; public void toggleSpeaker() { isLoud = !isLoud; if (isLoud) { speakBut.setCircleColor(Color.parseColor(global.puller.storedData.carrierCi.foreGround)); speakerImage.setBackgroundColor(Color.WHITE); speakerImage.setColorFilter(Color.parseColor(global.puller.storedData.carrierCi.foreGround), PorterDuff.Mode.SRC_IN); AudioDevice[] allDevices=INNTELApplication.coreContext.core.getAudioDevices(); for(int i=0;i 0) global.puller.storedData.callList.get(global.puller.storedData.callList.size() - 1).duration = secondspassed; global.puller.saveStoredData(); super.onBackPressed(); } public CircleView muteBut; public CircleView speakBut; public BetterImageView muteImage; public BetterImageView speakerImage; public void addTelephoneButton(int circleWidth, LinearLayout butRow, String genus) { RelativeLayout layout = new RelativeLayout(this); layout.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT)); butRow.addView(layout); if ("hoerer".equals(genus)) { theBut = new CircleView(this); theBut.setCircleColor(Color.RED); View.OnClickListener numberButListener = new View.OnClickListener() { @Override public void onClick(View v) { System.out.println("auflegbutpressed"); downPressed(); } }; theBut.setOnClickListener(numberButListener); theBut.setLayoutParams(new LinearLayout.LayoutParams(global.appleW(circleWidth), global.appleH(circleWidth))); layout.addView(theBut); } else if ("mute".equals(genus)) { muteBut = new CircleView(this); muteBut.setCircleColor(Color.WHITE); View.OnClickListener numberButListener = new View.OnClickListener() { @Override public void onClick(View v) { System.out.println("mutepressed"); toggleMute(); } }; muteBut.setOnClickListener(numberButListener); muteBut.setLayoutParams(new LinearLayout.LayoutParams(global.appleW(circleWidth), global.appleH(circleWidth))); layout.addView(muteBut); } else { speakBut = new CircleView(this); speakBut.setCircleColor(Color.WHITE); View.OnClickListener numberButListener = new View.OnClickListener() { @Override public void onClick(View v) { System.out.println("speaker"); toggleSpeaker(); } }; speakBut.setOnClickListener(numberButListener); speakBut.setLayoutParams(new LinearLayout.LayoutParams(global.appleW(circleWidth), global.appleH(circleWidth))); layout.addView(speakBut); } LinearLayout captionStack = new LinearLayout(this); captionStack.setLayoutParams(new LinearLayout.LayoutParams(global.appleW(circleWidth), global.appleH(circleWidth))); captionStack.setOrientation(LinearLayout.VERTICAL); captionStack.setHorizontalGravity(Gravity.CENTER); layout.addView(captionStack); if ("hoerer".equals(genus)) { BetterImageView dialImage = new BetterImageView(this); LinearLayout.LayoutParams dialImageParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, global.appleH(35)); dialImageParams.setMargins(0, global.appleH(16), 0, 0); dialImage.setLayoutParams(dialImageParams); dialImage.setScaleType(ImageView.ScaleType.CENTER_INSIDE); dialImage.setAdjustViewBounds(true); dialImage.setImageResource(R.drawable.hoererdown); dialImage.setBackgroundColor(Color.parseColor(global.puller.storedData.carrierCi.backGround)); dialImage.setColorFilter(Color.RED, PorterDuff.Mode.SRC_IN); captionStack.addView(dialImage); } else if ("mute".equals(genus)) { muteImage = new BetterImageView(this); LinearLayout.LayoutParams dialImageParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, global.appleH(45)); dialImageParams.setMargins(0, global.appleH(11), 0, 0); muteImage.setLayoutParams(dialImageParams); muteImage.setScaleType(ImageView.ScaleType.CENTER_INSIDE); muteImage.setAdjustViewBounds(true); muteImage.setImageResource(R.drawable.mute); muteImage.setBackgroundColor(Color.parseColor(global.puller.storedData.carrierCi.foreGround)); muteImage.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_IN); captionStack.addView(muteImage); } else { speakerImage = new BetterImageView(this); LinearLayout.LayoutParams dialImageParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, global.appleH(45)); dialImageParams.setMargins(0, global.appleH(11), 0, 0); speakerImage.setLayoutParams(dialImageParams); speakerImage.setScaleType(ImageView.ScaleType.CENTER_INSIDE); speakerImage.setAdjustViewBounds(true); speakerImage.setImageResource(R.drawable.loud); speakerImage.setBackgroundColor(Color.parseColor(global.puller.storedData.carrierCi.foreGround)); speakerImage.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_IN); captionStack.addView(speakerImage); } } } package at.inntelco.INNTEL.home; import android.annotation.SuppressLint; import android.app.Notification; import android.app.NotificationManager; import android.content.Context; import android.content.Intent; import android.content.res.ColorStateList; import android.graphics.Color; import android.graphics.PorterDuff; import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.text.InputType; import android.util.TypedValue; import android.view.Gravity; import android.view.KeyEvent; import android.view.View; import android.view.WindowManager; import android.view.inputmethod.BaseInputConnection; import android.view.inputmethod.InputMethodManager; import android.widget.EditText; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.TextView; import androidx.core.app.NotificationCompat; import com.google.android.material.bottomnavigation.BottomNavigationView; import org.linphone.core.Address; import org.linphone.core.AudioDevice; import org.linphone.core.CallParams; import org.linphone.core.Factory; import org.linphone.core.MediaEncryption; import org.linphone.core.Reason; import org.w3c.dom.Text; import at.inntelco.INNTEL.BetterActivity; import at.inntelco.INNTEL.BetterImageView; import at.inntelco.INNTEL.CircleView; import at.inntelco.INNTEL.LoadingScreen; import at.inntelco.INNTEL.INNTELApplication; import at.inntelco.INNTEL.R; import at.inntelco.INNTEL.Utilities; import at.inntelco.INNTEL.data.CallEntity; public class CallingScreenLocked extends BetterActivity { public TextView headLine; public CircleView theBut; public TextView timeLine; public CallEntity entity = null; public AvatarRow avatarRow; public boolean countdownrunning = false; public boolean hangupchecking = false; private Runnable mCheckForTimePassedRunnable = new Runnable() { @Override public void run() { if(countdownrunning) { secondspassed++; int mins = secondspassed / 60; int secs = secondspassed - (mins * 60); timeLine.setText(mins + ":" + secs); keepOnDoingTime.postDelayed(this, 1000); }else secondspassed = 0; } }; private Runnable mCheckForHangupRunnable = new Runnable() { @Override public void run() { if(hangupchecking) { if (!INNTELApplication.coreContext.callRunning) { partnerDidHangUp(); } keepOnDoingHangupCheck.postDelayed(this, 1000); } } }; public int secondspassed = 0; public Handler keepOnDoingTime; public Handler keepOnDoingHangupCheck; private void checkForLogIn() { if (avatarRow != null) { if (INNTELApplication.coreContext.loggedIn) { avatarRow.knoedel.setCircleColor(Color.GREEN); avatarRow.onlineImage.setImageResource(R.drawable.online); } else { avatarRow.knoedel.setCircleColor(Color.RED); avatarRow.onlineImage.setImageResource(R.drawable.offline); } avatarRow.setDropDownSelectionWithoutAction(global.puller.storedData.avatarDropdownSelection); } } @Override protected void onResume() { super.onResume(); if(INNTELApplication.coreContext.core.getCurrentCall()==null){ Intent newIntent = new Intent(this, Contacts.class); newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); startActivity(newIntent); }else { checkForLogIn(); navigation.getMenu().getItem(0).setChecked(false); navigation.getMenu().getItem(1).setChecked(false); navigation.getMenu().getItem(2).setChecked(false); navigation.getMenu().getItem(3).setChecked(false); navigation.getMenu().getItem(0).setEnabled(false); navigation.getMenu().getItem(1).setEnabled(false); navigation.getMenu().getItem(2).setEnabled(false); navigation.getMenu().getItem(3).setEnabled(false); avatarRow.languageSelector.setEnabled(false); avatarRow.onlineImage.setClickable(false); NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.cancel(0); hangupchecking = true; INNTELApplication.coreContext.callRunning = true; } } @SuppressLint("MissingSuperCall") @Override public void onBackPressed() { } private void showWhenLockedAndTurnScreenOn() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) { setShowWhenLocked(true); setTurnScreenOn(true); } else { getWindow().addFlags( WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON ); } } @Override protected void onCreate(Bundle savedInstanceState) { INNTELApplication application = (INNTELApplication) getApplication(); global = application.global; showWhenLockedAndTurnScreenOn(); super.onCreate(savedInstanceState); setStatusBarColorNow(global.puller.storedData.carrierCi.foreGround); setContentView(R.layout.activity_calling); BottomNavigationView.OnNavigationItemSelectedListener listener = new BottomNavigationListener(this, global, this); navigation = (BottomNavigationView) findViewById(R.id.navigation); Utilities.createMenu(navigation, global); ColorStateList iconTintList = ColorStateList.valueOf(Color.parseColor(global.puller.storedData.carrierCi.foreGround)); int[][] states = new int[][]{ new int[]{android.R.attr.state_checked}, // checked new int[]{-android.R.attr.state_checked} // unchecked }; int[] colors = new int[]{ Color.GRAY, // for checked state Color.GRAY // for unchecked state }; ColorStateList colorStateList = new ColorStateList(states, colors); navigation.setItemIconTintList(colorStateList); navigation.setItemTextColor(colorStateList); //navigation.setOnNavigationItemSelectedListener(listener); entity = global.puller.storedData.callEntity; progressDialog = new LoadingScreen(this, global); progressDialog.show(); buildGUI(); } public void buildGUI() { LinearLayout fixedUpperStack = findViewById(R.id.fixedUpperStack); fixedUpperStack.setGravity(Gravity.CENTER); fixedUpperStack.setClipChildren(false); addVerticalSpacer(fixedUpperStack, 8, this); fixedUpperStack.setBackgroundColor(Color.parseColor(global.puller.storedData.carrierCi.foreGround)); avatarRow = new AvatarRow(this, this); fixedUpperStack.addView(avatarRow); addVerticalSpacer(fixedUpperStack, 8, this); LinearLayout fixedLowerStack = findViewById(R.id.fixedLowerStack); fixedLowerStack.setOrientation(LinearLayout.VERTICAL); fixedLowerStack.setHorizontalGravity(Gravity.CENTER); fixedLowerStack.setVerticalGravity(Gravity.CENTER); fixedLowerStack.setBackgroundColor(Color.parseColor(global.puller.storedData.carrierCi.backGround)); addVerticalSpacer(fixedLowerStack, 18, this); headLine = new TextView(this); headLine.setText(global.puller.storedData.callEntity.user.mobile); headLine.setTextSize(TypedValue.COMPLEX_UNIT_PX, global.appleH(32)); headLine.setTextAlignment(View.TEXT_ALIGNMENT_CENTER); headLine.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); headLine.setTextColor(Color.parseColor(global.puller.storedData.carrierCi.foreGround)); headLine.setBackgroundColor(Color.parseColor(global.puller.storedData.carrierCi.backGround)); headLine.setSingleLine(true); fixedLowerStack.addView(headLine); addVerticalSpacer(fixedLowerStack, 18, this); TextView headLineSub = new TextView(this); headLineSub.setText(global.puller.storedData.callEntity.user.lastname); headLineSub.setTextSize(TypedValue.COMPLEX_UNIT_PX, global.appleH(18)); headLineSub.setTextAlignment(View.TEXT_ALIGNMENT_CENTER); headLineSub.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); headLineSub.setTextColor(Color.parseColor(global.puller.storedData.carrierCi.foreGround)); headLineSub.setBackgroundColor(Color.parseColor(global.puller.storedData.carrierCi.backGround)); headLineSub.setSingleLine(true); fixedLowerStack.addView(headLineSub); addVerticalSpacer(fixedLowerStack, 8, this); timeLine = new TextView(this); timeLine.setText("00:00"); timeLine.setTextSize(TypedValue.COMPLEX_UNIT_PX, global.appleH(18)); timeLine.setTextAlignment(View.TEXT_ALIGNMENT_CENTER); timeLine.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); timeLine.setTextColor(Color.parseColor(global.puller.storedData.carrierCi.foreGround)); timeLine.setBackgroundColor(Color.parseColor(global.puller.storedData.carrierCi.backGround)); timeLine.setSingleLine(true); fixedLowerStack.addView(timeLine); addVerticalSpacer(fixedLowerStack, 32, this); int rand = 60; int space = 30; int vspace = 16; LinearLayout firstButRow = new LinearLayout(this); firstButRow.setOrientation(LinearLayout.HORIZONTAL); fixedLowerStack.addView(firstButRow); int circleWidth = (375 - (rand + space + space + rand)) / 3; int thisrand = (375 - (2 * circleWidth) - space) / 2; addHorizontalSpacer(firstButRow, thisrand, this); addTelephoneButton(circleWidth, firstButRow, "mute"); addHorizontalSpacer(firstButRow, space, this); addTelephoneButton(circleWidth, firstButRow, "loud"); addHorizontalSpacer(firstButRow, thisrand, this); addVerticalSpacer(fixedLowerStack, 3 * vspace, this); LinearLayout fifthButRow = new LinearLayout(this); fifthButRow.setOrientation(LinearLayout.HORIZONTAL); fifthButRow.setHorizontalGravity(Gravity.CENTER); fifthButRow.setVerticalGravity(Gravity.CENTER); fixedLowerStack.addView(fifthButRow); addHorizontalSpacer(fifthButRow, thisrand, this); addTelephoneButton(circleWidth, fifthButRow, "hoererdecline"); addTelephoneButton(circleWidth, fifthButRow, "hoererdown"); addHorizontalSpacer(fifthButRow, space, this); addTelephoneButton(circleWidth, fifthButRow, "hoererup"); addTelephoneButton(circleWidth, fifthButRow, "hoererupgray"); addHorizontalSpacer(fifthButRow, thisrand, this); hoererdownButL.setVisibility(View.GONE); hoererupgrayButL.setVisibility(View.GONE); hideLoadingScreenIfNothingLeftToWaitFor(); keepOnDoingTime = new Handler(); keepOnDoingHangupCheck = new Handler(); hangupchecking = true; keepOnDoingHangupCheck.postDelayed(mCheckForHangupRunnable, 1000); } public boolean isMute = false; public void toggleMute() { isMute = !isMute; if (isMute) { muteBut.setCircleColor(Color.parseColor(global.puller.storedData.carrierCi.foreGround)); muteImage.setBackgroundColor(Color.WHITE); muteImage.setColorFilter(Color.parseColor(global.puller.storedData.carrierCi.foreGround), PorterDuff.Mode.SRC_IN); INNTELApplication.coreContext.core.setMicEnabled(false); } else { muteBut.setCircleColor(Color.WHITE); muteImage.setBackgroundColor(Color.parseColor(global.puller.storedData.carrierCi.foreGround)); muteImage.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_IN); INNTELApplication.coreContext.core.setMicEnabled(true); } } public boolean isLoud = false; public AudioDevice.Type originalType; public void toggleSpeaker() { isLoud = !isLoud; if (isLoud) { speakBut.setCircleColor(Color.parseColor(global.puller.storedData.carrierCi.foreGround)); speakerImage.setBackgroundColor(Color.WHITE); speakerImage.setColorFilter(Color.parseColor(global.puller.storedData.carrierCi.foreGround), PorterDuff.Mode.SRC_IN); AudioDevice[] allDevices=INNTELApplication.coreContext.core.getAudioDevices(); for(int i=0;i 0) { global.puller.storedData.callList.get(global.puller.storedData.callList.size() - 1).duration = 0; global.puller.storedData.callList.get(global.puller.storedData.callList.size() - 1).success = false; } global.puller.saveStoredData(); countdownrunning = false; hangupchecking = false; super.onBackPressed(); } public void upPressed() { INNTELApplication.coreContext.core.getCurrentCall().accept(); countdownrunning = true; keepOnDoingTime.postDelayed(mCheckForTimePassedRunnable, 1000); hoererupButL.setVisibility(View.GONE); hoererupgrayButL.setVisibility(View.VISIBLE); hoererdeclineButL.setVisibility(View.GONE); hoererdownButL.setVisibility(View.VISIBLE); } public void downPressed() { INNTELApplication.coreContext.core.getCurrentCall().terminate(); if (global.puller.storedData.callList.size() > 0) global.puller.storedData.callList.get(global.puller.storedData.callList.size() - 1).duration = secondspassed; global.puller.saveStoredData(); countdownrunning = false; hangupchecking = false; hoererupButL.setVisibility(View.VISIBLE); hoererupgrayButL.setVisibility(View.GONE); hoererdeclineButL.setVisibility(View.VISIBLE); hoererdownButL.setVisibility(View.GONE); super.onBackPressed(); } public void partnerDidHangUp(){ if (global.puller.storedData.callList.size() > 0) global.puller.storedData.callList.get(global.puller.storedData.callList.size() - 1).duration = secondspassed; global.puller.saveStoredData(); countdownrunning = false; hangupchecking = false; hoererupButL.setVisibility(View.VISIBLE); hoererupgrayButL.setVisibility(View.GONE); hoererdeclineButL.setVisibility(View.VISIBLE); hoererdownButL.setVisibility(View.GONE); super.onBackPressed(); } public CircleView muteBut; public CircleView speakBut; public RelativeLayout hoererdeclineButL; public RelativeLayout hoererdownButL; public RelativeLayout hoererupButL; public RelativeLayout hoererupgrayButL; public BetterImageView muteImage; public BetterImageView speakerImage; public void addTelephoneButton(int circleWidth, LinearLayout butRow, String genus) { if ("hoererdecline".equals(genus)) { hoererdeclineButL = new RelativeLayout(this); hoererdeclineButL.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT)); butRow.addView(hoererdeclineButL); CircleView hoererdeclineBut = new CircleView(this); hoererdeclineBut.setCircleColor(Color.RED); View.OnClickListener numberButListener = new View.OnClickListener() { @Override public void onClick(View v) { System.out.println("declinebutpressed"); declinePressed(); } }; hoererdeclineBut.setOnClickListener(numberButListener); hoererdeclineBut.setLayoutParams(new LinearLayout.LayoutParams(global.appleW(circleWidth), global.appleH(circleWidth))); hoererdeclineButL.addView(hoererdeclineBut); LinearLayout captionStack = new LinearLayout(this); captionStack.setLayoutParams(new LinearLayout.LayoutParams(global.appleW(circleWidth), global.appleH(circleWidth))); captionStack.setOrientation(LinearLayout.VERTICAL); captionStack.setHorizontalGravity(Gravity.CENTER); BetterImageView dialImage = new BetterImageView(this); LinearLayout.LayoutParams dialImageParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, global.appleH(35)); dialImageParams.setMargins(0, global.appleH(16), 0, 0); dialImage.setLayoutParams(dialImageParams); dialImage.setScaleType(ImageView.ScaleType.CENTER_INSIDE); dialImage.setAdjustViewBounds(true); dialImage.setImageResource(R.drawable.hoererdown); dialImage.setBackgroundColor(Color.parseColor(global.puller.storedData.carrierCi.backGround)); dialImage.setColorFilter(Color.RED, PorterDuff.Mode.SRC_IN); captionStack.addView(dialImage); hoererdeclineButL.addView(captionStack); } else if ("hoererdown".equals(genus)) { hoererdownButL = new RelativeLayout(this); hoererdownButL.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT)); butRow.addView(hoererdownButL); CircleView hoererdownBut = new CircleView(this); hoererdownBut.setCircleColor(Color.RED); View.OnClickListener numberButListener = new View.OnClickListener() { @Override public void onClick(View v) { System.out.println("downbutpressed"); downPressed(); } }; hoererdownBut.setOnClickListener(numberButListener); hoererdownBut.setLayoutParams(new LinearLayout.LayoutParams(global.appleW(circleWidth), global.appleH(circleWidth))); hoererdownButL.addView(hoererdownBut); LinearLayout captionStack = new LinearLayout(this); captionStack.setLayoutParams(new LinearLayout.LayoutParams(global.appleW(circleWidth), global.appleH(circleWidth))); captionStack.setOrientation(LinearLayout.VERTICAL); captionStack.setHorizontalGravity(Gravity.CENTER); BetterImageView dialImage = new BetterImageView(this); LinearLayout.LayoutParams dialImageParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, global.appleH(35)); dialImageParams.setMargins(0, global.appleH(16), 0, 0); dialImage.setLayoutParams(dialImageParams); dialImage.setScaleType(ImageView.ScaleType.CENTER_INSIDE); dialImage.setAdjustViewBounds(true); dialImage.setImageResource(R.drawable.hoererdown); dialImage.setBackgroundColor(Color.parseColor(global.puller.storedData.carrierCi.backGround)); dialImage.setColorFilter(Color.RED, PorterDuff.Mode.SRC_IN); captionStack.addView(dialImage); hoererdownButL.addView(captionStack); } else if ("hoererup".equals(genus)) { hoererupButL = new RelativeLayout(this); hoererupButL.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT)); butRow.addView(hoererupButL); CircleView hoererupBut = new CircleView(this); hoererupBut.setCircleColor(Color.parseColor("#66CC66")); View.OnClickListener numberButListener = new View.OnClickListener() { @Override public void onClick(View v) { System.out.println("upbutpressed"); upPressed(); } }; hoererupBut.setOnClickListener(numberButListener); hoererupBut.setLayoutParams(new LinearLayout.LayoutParams(global.appleW(circleWidth), global.appleH(circleWidth))); hoererupButL.addView(hoererupBut); LinearLayout captionStack = new LinearLayout(this); captionStack.setLayoutParams(new LinearLayout.LayoutParams(global.appleW(circleWidth), global.appleH(circleWidth))); captionStack.setOrientation(LinearLayout.VERTICAL); captionStack.setHorizontalGravity(Gravity.CENTER); BetterImageView dialImage = new BetterImageView(this); LinearLayout.LayoutParams dialImageParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, global.appleH(35)); dialImageParams.setMargins(0, global.appleH(16), 0, 0); dialImage.setLayoutParams(dialImageParams); dialImage.setScaleType(ImageView.ScaleType.CENTER_INSIDE); dialImage.setAdjustViewBounds(true); dialImage.setImageResource(R.drawable.hoerer); dialImage.setBackgroundColor(Color.parseColor(global.puller.storedData.carrierCi.backGround)); dialImage.setColorFilter(Color.parseColor("#66CC66"), PorterDuff.Mode.SRC_IN); captionStack.addView(dialImage); hoererupButL.addView(captionStack); } else if ("hoererupgray".equals(genus)) { hoererupgrayButL = new RelativeLayout(this); hoererupgrayButL.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT)); butRow.addView(hoererupgrayButL); CircleView hoererupgrayBut = new CircleView(this); hoererupgrayBut.setCircleColor(Color.GRAY); hoererupgrayBut.setLayoutParams(new LinearLayout.LayoutParams(global.appleW(circleWidth), global.appleH(circleWidth))); hoererupgrayButL.addView(hoererupgrayBut); LinearLayout captionStack = new LinearLayout(this); captionStack.setLayoutParams(new LinearLayout.LayoutParams(global.appleW(circleWidth), global.appleH(circleWidth))); captionStack.setOrientation(LinearLayout.VERTICAL); captionStack.setHorizontalGravity(Gravity.CENTER); BetterImageView dialImage = new BetterImageView(this); LinearLayout.LayoutParams dialImageParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, global.appleH(35)); dialImageParams.setMargins(0, global.appleH(16), 0, 0); dialImage.setLayoutParams(dialImageParams); dialImage.setScaleType(ImageView.ScaleType.CENTER_INSIDE); dialImage.setAdjustViewBounds(true); dialImage.setImageResource(R.drawable.hoerer); dialImage.setBackgroundColor(Color.parseColor(global.puller.storedData.carrierCi.backGround)); dialImage.setColorFilter(Color.GRAY, PorterDuff.Mode.SRC_IN); captionStack.addView(dialImage); hoererupgrayButL.addView(captionStack); } else if ("mute".equals(genus)) { RelativeLayout muteButL = new RelativeLayout(this); muteButL.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT)); butRow.addView(muteButL); muteBut = new CircleView(this); muteBut.setCircleColor(Color.WHITE); View.OnClickListener numberButListener = new View.OnClickListener() { @Override public void onClick(View v) { System.out.println("mutepressed"); toggleMute(); } }; muteBut.setOnClickListener(numberButListener); muteBut.setLayoutParams(new LinearLayout.LayoutParams(global.appleW(circleWidth), global.appleH(circleWidth))); muteButL.addView(muteBut); LinearLayout captionStack = new LinearLayout(this); captionStack.setLayoutParams(new LinearLayout.LayoutParams(global.appleW(circleWidth), global.appleH(circleWidth))); captionStack.setOrientation(LinearLayout.VERTICAL); captionStack.setHorizontalGravity(Gravity.CENTER); muteImage = new BetterImageView(this); LinearLayout.LayoutParams dialImageParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, global.appleH(45)); dialImageParams.setMargins(0, global.appleH(11), 0, 0); muteImage.setLayoutParams(dialImageParams); muteImage.setScaleType(ImageView.ScaleType.CENTER_INSIDE); muteImage.setAdjustViewBounds(true); muteImage.setImageResource(R.drawable.mute); muteImage.setBackgroundColor(Color.parseColor(global.puller.storedData.carrierCi.foreGround)); muteImage.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_IN); captionStack.addView(muteImage); muteButL.addView(captionStack); } else { RelativeLayout speakButL = new RelativeLayout(this); speakButL.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT)); butRow.addView(speakButL); speakBut = new CircleView(this); speakBut.setCircleColor(Color.WHITE); View.OnClickListener numberButListener = new View.OnClickListener() { @Override public void onClick(View v) { System.out.println("speaker"); toggleSpeaker(); } }; speakBut.setOnClickListener(numberButListener); speakBut.setLayoutParams(new LinearLayout.LayoutParams(global.appleW(circleWidth), global.appleH(circleWidth))); speakButL.addView(speakBut); LinearLayout captionStack = new LinearLayout(this); captionStack.setLayoutParams(new LinearLayout.LayoutParams(global.appleW(circleWidth), global.appleH(circleWidth))); captionStack.setOrientation(LinearLayout.VERTICAL); captionStack.setHorizontalGravity(Gravity.CENTER); speakerImage = new BetterImageView(this); LinearLayout.LayoutParams dialImageParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, global.appleH(45)); dialImageParams.setMargins(0, global.appleH(11), 0, 0); speakerImage.setLayoutParams(dialImageParams); speakerImage.setScaleType(ImageView.ScaleType.CENTER_INSIDE); speakerImage.setAdjustViewBounds(true); speakerImage.setImageResource(R.drawable.loud); speakerImage.setBackgroundColor(Color.parseColor(global.puller.storedData.carrierCi.foreGround)); speakerImage.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_IN); captionStack.addView(speakerImage); speakButL.addView(captionStack); } } } package at.inntelco.INNTEL.home; import android.Manifest; import android.annotation.SuppressLint; import android.content.ContentResolver; import android.content.Intent; import android.content.pm.PackageManager; import android.content.res.ColorStateList; import android.database.Cursor; import android.graphics.Color; import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; import android.provider.ContactsContract; import android.text.Editable; import android.text.TextWatcher; import android.util.TypedValue; import android.view.Gravity; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.view.inputmethod.EditorInfo; import android.widget.EditText; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ScrollView; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.constraintlayout.widget.ConstraintLayout; import androidx.core.app.ActivityCompat; import com.google.android.material.bottomnavigation.BottomNavigationView; import com.google.gson.Gson; import com.google.gson.stream.JsonReader; import org.linphone.core.Address; //import org.linphone.core.ConsolidatedPresence; import org.linphone.core.Core; import org.linphone.core.Factory; import org.linphone.core.Friend; import org.linphone.core.FriendList; //import org.linphone.core.FriendListener; //import org.linphone.core.FriendPhoneNumber; //import org.linphone.core.PresenceModel; //import org.linphone.core.SubscribePolicy; //import org.linphone.core.SubscriptionState; import org.linphone.core.TransportType; //import org.linphone.core.Vcard; import at.inntelco.INNTEL.BetterActivity; import at.inntelco.INNTEL.BetterImageView; import at.inntelco.INNTEL.CircleView; import at.inntelco.INNTEL.LoadingScreen; import at.inntelco.INNTEL.INNTELApplication; import at.inntelco.INNTEL.R; import at.inntelco.INNTEL.Utilities; import at.inntelco.INNTEL.data.CallEntity; import at.inntelco.INNTEL.data.User; import java.io.StringReader; import java.util.ArrayList; import java.util.Comparator; import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashMap; public class Contacts extends BetterActivity { public ScrollView scrollView; public FilterButton firstButBack; public FilterButton secondButBack; public FilterButton thirdButBack; public String abc = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; public HashMap letterPositions; public LinearLayout theStack; public ArrayList sortedContacts; public AvatarRow avatarRow; public Handler keepOnDoing; public String filteredBy = ""; private Runnable mCheckForLoginRunnable = new Runnable() { @Override public void run() { checkForLogIn(); keepOnDoing.postDelayed(this, 2000); } }; private boolean processed = false; private void checkForLogIn() { if (avatarRow != null) { if (INNTELApplication.coreContext.loggedIn && global.puller.storedData.user!=null) { for(int i=0;i0) { FriendList firstFriendList = friendLists[0]; Friend[] friends=firstFriendList.getFriends(); for(int j=0;j0) { FriendList firstFriendList = friendLists[0]; Friend[] friends=firstFriendList.getFriends(); for(int i=0;i(); keepOnAsking(); } public final int REQUEST_PERMISSION_PHONE_CONTACTS = 25; public final int REQUEST_PERMISSION_RECORD_AUDIO = 26; public final int REQUEST_PERMISSION_SETTING = 27; @SuppressLint("MissingSuperCall") @Override public void onRequestPermissionsResult( int requestCode, String permissions[], int[] grantResults) { boolean deniedSomething=false; switch (requestCode) { case REQUEST_PERMISSION_PHONE_CONTACTS: if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { System.out.println("Contact Permission granted."); } else { System.out.println("Contact Permission denied."); deniedSomething=true; } case REQUEST_PERMISSION_RECORD_AUDIO: if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { System.out.println("Audio Permission granted."); } else { System.out.println("Audio Permission denied."); deniedSomething=true; } } boolean neverShowAgainCheckboxChecked = !shouldShowRequestPermissionRationale( permissions[0] ); if (deniedSomething && neverShowAgainCheckboxChecked) { System.out.println("Never show Again checkbox Checked. "); Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS); Uri uri = Uri.fromParts("package", getPackageName(), null); intent.setData(uri); startActivityForResult(intent, REQUEST_PERMISSION_SETTING); }else keepOnAsking(); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == REQUEST_PERMISSION_SETTING) { keepOnAsking(); } } public void keepOnAsking() { System.out.println("asking..."); if (checkSelfPermission(Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_CONTACTS}, REQUEST_PERMISSION_PHONE_CONTACTS); } else { if (checkSelfPermission(Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.RECORD_AUDIO}, REQUEST_PERMISSION_RECORD_AUDIO); }else { progressDialog = new LoadingScreen(Contacts.this, global); progressDialog.show(); //if (global.puller.storedData.user == null) new LoadingTask().execute(); //else // buildGUI(); } } } public void performSearch(String word, String filter) { theStack.removeAllViews(); letterPositions = new HashMap(); for (int i = 0; i < sortedContacts.size(); i++) { User act = sortedContacts.get(i); String testString = act.firstname + " " + act.lastname + " " + act.extension + act.mobile; testString = testString.toLowerCase(); if (testString.contains(word.toLowerCase()) || "".equals(word)) { if("cloud".equals(filter)){ if (!act.origin.equals("phone")) { LinearLayout theRow = addPhoneRow(theStack, act); String compo = act.lastname + act.firstname; String first = ""; if (compo.length() > 0) first = "" + compo.charAt(0); first = first.toUpperCase(); if (letterPositions.get(first) == null) { letterPositions.put(first, theRow); } } }else if (act.origin.equals(filter) || "".equals(filter)) { LinearLayout theRow = addPhoneRow(theStack, act); String compo = act.lastname + act.firstname; String first = ""; if (compo.length() > 0) first = "" + compo.charAt(0); first = first.toUpperCase(); if (letterPositions.get(first) == null) { letterPositions.put(first, theRow); } } } } } @Override public void onBackPressed() { super.onBackPressed(); View view = getCurrentFocus(); if (view != null) { view.clearFocus(); } } public void buildGUI() { int upperHeight = 0; LinearLayout fixedUpperStack = findViewById(R.id.fixedUpperStack); fixedUpperStack.setGravity(Gravity.CENTER); fixedUpperStack.setClipChildren(false); addVerticalSpacer(fixedUpperStack, 8, this); upperHeight += 8; fixedUpperStack.setBackgroundColor(Color.parseColor(global.puller.storedData.carrierCi.foreGround)); upperHeight += 60; avatarRow = new AvatarRow(this, this); fixedUpperStack.addView(avatarRow); addVerticalSpacer(fixedUpperStack, 8, this); upperHeight += 8; LinearLayout fixedLowerStack = findViewById(R.id.fixedLowerStack); fixedLowerStack.setOrientation(LinearLayout.VERTICAL); fixedLowerStack.setBackgroundColor(Color.parseColor(global.puller.storedData.carrierCi.backGround)); addVerticalSpacer(fixedLowerStack, 8, this); upperHeight += 8; LinearLayout searchRow = new LinearLayout(this); searchRow.setOrientation(LinearLayout.HORIZONTAL); addHorizontalSpacer(searchRow, 20, this); EditText searchText = new EditText(this); searchText.setLayoutParams(new LinearLayout.LayoutParams(global.appleW(375 - (20 + 8 + 35 + 8)), LinearLayout.LayoutParams.WRAP_CONTENT)); searchText.setHint(global.getTranslation("contacts")); searchText.setHintTextColor(Color.GRAY); searchText.setTextSize(TypedValue.COMPLEX_UNIT_PX, global.appleH(20)); searchText.setTextAlignment(View.TEXT_ALIGNMENT_TEXT_START); searchText.setTextColor(global.textColor); searchText.setBackgroundColor(Color.parseColor(global.puller.storedData.carrierCi.backGround)); searchText.setSingleLine(true); searchText.setSelectAllOnFocus(true); searchText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { boolean handled = false; if (actionId == EditorInfo.IME_ACTION_DONE) { hideKeyboard(); handled = true; } return handled; } }); searchText.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { String searchedFor = s.toString(); performSearch(searchedFor, filteredBy); } }); searchRow.addView(searchText); addHorizontalSpacer(searchRow, 8, this); BetterImageView searchImage = new BetterImageView(this); LinearLayout.LayoutParams searchImageParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, global.appleH(35)); upperHeight += 35; searchImage.setLayoutParams(searchImageParams); searchImage.setScaleType(ImageView.ScaleType.CENTER_INSIDE); searchImage.setAdjustViewBounds(true); searchImage.setImageResource(R.drawable.searchlense); View.OnClickListener searchButListener = new View.OnClickListener() { @Override public void onClick(View v) { System.out.println("searchButPressed."); System.out.println("searchtext:" + searchText.getText().toString()); performSearch(searchText.getText().toString(), ""); hideKeyboard(); } }; searchImage.setOnClickListener(searchButListener); searchRow.addView(searchImage); addHorizontalSpacer(searchRow, 8, this); fixedLowerStack.addView(searchRow); LinearLayout searchButRow = new LinearLayout(this); searchButRow.setOrientation(LinearLayout.HORIZONTAL); addHorizontalSpacer(searchButRow, 12 + 3, this); View.OnClickListener firstButListener = new View.OnClickListener() { @Override public void onClick(View v) { filteredBy = ""; System.out.println("firstButPressed."); if (firstButBack.isSelected()) { firstButBack.unSelect(); } else { firstButBack.select(); secondButBack.unSelect(); thirdButBack.unSelect(); filteredBy = "cloud"; } performSearch(searchText.getText().toString(), filteredBy); } }; int buttonHeight = 35; firstButBack = new FilterButton(global.getTranslation("cloud"), firstButListener, this, (375 - 24) / 3, buttonHeight); searchButRow.addView(firstButBack.butBack); View.OnClickListener secondButListener = new View.OnClickListener() { @Override public void onClick(View v) { System.out.println("secondButPressed."); filteredBy = ""; if (secondButBack.isSelected()) { secondButBack.unSelect(); } else { firstButBack.unSelect(); secondButBack.select(); thirdButBack.unSelect(); filteredBy = "internal"; } performSearch(searchText.getText().toString(), filteredBy); } }; secondButBack = new FilterButton(global.getTranslation("internal"), secondButListener, this, (375 - 24) / 3, buttonHeight); searchButRow.addView(secondButBack.butBack); View.OnClickListener thirdButListener = new View.OnClickListener() { @Override public void onClick(View v) { System.out.println("thirdButPressed."); filteredBy = ""; if (thirdButBack.isSelected()) { thirdButBack.unSelect(); } else { firstButBack.unSelect(); secondButBack.unSelect(); thirdButBack.select(); filteredBy = "phone"; } performSearch(searchText.getText().toString(), filteredBy); } }; thirdButBack = new FilterButton(global.getTranslation("phone"), thirdButListener, this, (375 - 24) / 3, buttonHeight); searchButRow.addView(thirdButBack.butBack); addHorizontalSpacer(searchButRow, 12 + 3, this); fixedLowerStack.addView(searchButRow); upperHeight += buttonHeight; addVerticalSpacer(fixedLowerStack, 8, this); upperHeight += 8; scrollView = findViewById(R.id.scrollview); scrollView.setBackgroundColor(Color.parseColor(global.puller.storedData.carrierCi.backGround)); ViewGroup.LayoutParams scrollParams = scrollView.getLayoutParams(); scrollParams.width = global.appleW(375 - 20); LinearLayout theAbc = findViewById(R.id.abc); int totalHeight = global.heightPixels; int resourceId = getResources().getIdentifier("design_bottom_navigation_height", "dimen", this.getPackageName()); int naviHeight = 0; if (resourceId > 0) { naviHeight = getResources().getDimensionPixelSize(resourceId); } int abcHeight = totalHeight - naviHeight - global.appleH(upperHeight+34); System.out.println("ABCHeight: "+abcHeight+" upperHeight: "+upperHeight+" naviheight:"+naviHeight); theAbc.setLayoutParams(new LinearLayout.LayoutParams(global.appleW(20), abcHeight)); int letterSize = abcHeight / abc.length(); for (int i = 0; i < abc.length(); i++) { addLetterBut("" + abc.charAt(i), theAbc, letterSize); } theAbc.setBackgroundColor(Color.parseColor(global.puller.storedData.carrierCi.backGround)); theStack = findViewById(R.id.itemstack); theStack.setGravity(Gravity.CENTER); theStack.setClipChildren(false); sortedContacts = global.puller.storedData.user.contacts; sortedContacts.sort(new Comparator() { public int compare(User userA, User userB) { String compoA = userA.lastname + userA.firstname; String compoB = userB.lastname + userB.firstname; return compoA.compareToIgnoreCase(compoB); } }); letterPositions = new HashMap(); for (int i = 0; i < sortedContacts.size(); i++) { User act = sortedContacts.get(i); LinearLayout theRow = addPhoneRow(theStack, act); String compo = act.lastname + act.firstname; String first = ""; if (compo.length() > 0) first = "" + compo.charAt(0); first = first.toUpperCase(); if (letterPositions.get(first) == null) { letterPositions.put(first, theRow); } } hideLoadingScreenIfNothingLeftToWaitFor(); keepOnDoing = new Handler(); keepOnDoing.postDelayed(mCheckForLoginRunnable, 2000); } public LinearLayout addPhoneRow(LinearLayout theStack, User user) { View hairLine = new View(this); hairLine.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 1)); hairLine.setBackgroundColor(Color.LTGRAY); theStack.addView(hairLine); LinearLayout phoneRow = new LinearLayout(this); phoneRow.setOrientation(LinearLayout.HORIZONTAL); phoneRow.setVerticalGravity(Gravity.CENTER); phoneRow.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, global.appleH(45))); addHorizontalSpacer(phoneRow, 12, this); TextView aLabel = new TextView(this); String klammer = ""; if (user.extension == null || "".equals(user.extension)) { if (user.mobile.length() > 7) { if (user.mobile.startsWith("+")) klammer = " (" + user.mobile.substring(0, 6) + ".." + user.mobile.substring(user.mobile.length() - 4) + ")"; else klammer = " (" + user.mobile.substring(0, 4) + ".." + user.mobile.substring(user.mobile.length() - 4) + ")"; } else { klammer = " (" + user.mobile + ")"; } } String theText = user.firstname + " " + user.lastname + klammer; theText = Utilities.removeLeadingSpaces(theText); aLabel.setText(theText); aLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX, global.appleH(20)); aLabel.setTextAlignment(View.TEXT_ALIGNMENT_TEXT_START); aLabel.setLayoutParams(new LinearLayout.LayoutParams(global.appleW(320), LinearLayout.LayoutParams.WRAP_CONTENT)); aLabel.setTextColor(global.textColor); phoneRow.addView(aLabel); System.out.println(user.origin); if (user.origin.equals("internal")) { CircleView status = new CircleView(this); status.setCircleColor(Color.GREEN); if (user.presence.equals("online")) status.setCircleColor(Color.GREEN); if (user.presence.equals("offline")) status.setCircleColor(Color.RED); if (user.presence.equals("calling")) status.setCircleColor(Color.BLUE); status.setLayoutParams(new LinearLayout.LayoutParams(global.appleW(12), global.appleH(12))); phoneRow.addView(status); user.status=status; } View.OnClickListener phoneRowListener = new View.OnClickListener() { @Override public void onClick(View v) { int[] locInWindow = new int[2]; phoneRow.getLocationOnScreen(locInWindow); System.out.println("phoneRowPressed:" + locInWindow[0] + " " + locInWindow[1]); contactTapped(user); } }; aLabel.setOnClickListener(phoneRowListener); System.out.println("C NOWa "+System.currentTimeMillis()); theStack.addView(phoneRow); System.out.println("C NOWb "+System.currentTimeMillis()); return phoneRow; } public void contactTapped(User user) { global.puller.storedData.callEntity = new CallEntity(global.puller.storedData.callList.size() + "", user, true, new Date()); global.puller.storedData.callList.add(global.puller.storedData.callEntity); global.puller.saveStoredData(); Intent newIntent = new Intent(this, CallingScreen.class); this.startActivity(newIntent); } public void addLetterBut(String caption, LinearLayout theAbc, int letterSize) { TextView aLabel = new TextView(this); aLabel.setText(caption); float letterHeight = letterSize * 0.8f; aLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX, letterHeight); aLabel.setTextAlignment(View.TEXT_ALIGNMENT_CENTER); aLabel.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, letterSize)); aLabel.setTextColor(global.textColor); View.OnClickListener letterButListener = new View.OnClickListener() { @Override public void onClick(View v) { System.out.println("letterButPressed:" + caption); int pos = abc.indexOf(caption); System.out.println("pos:" + pos); LinearLayout ret = null; for (int i = pos; i > -1; i--) { ret = letterPositions.get("" + abc.charAt(i)); System.out.println("i:" + i); if (ret != null) break; } if (ret != null) { float position = ret.getY(); scrollView.scrollTo(0, (int) position); System.out.println("scrolling to" + position); } } }; aLabel.setOnClickListener(letterButListener); theAbc.addView(aLabel); } @SuppressLint("Range") private void getContactList() { Cursor cursor = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null); if (cursor != null && cursor.getCount() > 0) { HashSet mobileNoSet = new HashSet(); while (cursor.moveToNext()) { @SuppressLint("Range") String contactId = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID) ); @SuppressLint("Range") String name = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME)); if (Integer.parseInt(cursor.getString( cursor.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER))) > 0) { Cursor phoneCursor = getContentResolver().query( ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = ?", new String[]{contactId}, null); while (phoneCursor != null && phoneCursor.moveToNext()) { String phoneNumber = phoneCursor.getString( phoneCursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)); System.out.println("Contact Name: " + name + ", Phone Number: " + phoneNumber); phoneNumber = Utilities.normalizeNumber(phoneNumber, global.puller.storedData.vorWahl); if (!mobileNoSet.contains(phoneNumber)) { User act = new User(); act.origin = "phone"; act.firstname = ""; act.lastname = name; act.mobile = phoneNumber; if (!global.puller.storedData.user.contacts.contains(act)) global.puller.storedData.user.contacts.add(act); mobileNoSet.add(phoneNumber); } } if (phoneCursor != null) { phoneCursor.close(); } } } } if (cursor != null) { cursor.close(); } } private class LoadingTask extends AsyncTask { protected void onPreExecute() { super.onPreExecute(); } protected String doInBackground(String... args) { LinkedHashMap params = new LinkedHashMap(); String ret = global.puller.webserviceCall("getuser", params, true, global.puller.storedData.loginInfo.apikey, global.puller.storedData.loginInfo.authorizedApiKey); System.out.println(ret); String json = ret; Gson gson = new Gson(); JsonReader reader = new JsonReader(new StringReader(json)); reader.setLenient(true); global.puller.storedData.user = gson.fromJson(reader, User.class); for(int i=0;i sortedContacts; public String lastFilteredBy = ""; public LinearLayout theStack; public AvatarRow avatarRow; private Runnable mCheckForLoginRunnable = new Runnable() { @Override public void run() { checkForLogIn(); keepOnDoing.postDelayed(this, 2000); } }; public Handler keepOnDoing; private void checkForLogIn() {if (avatarRow != null) { if (INNTELApplication.coreContext.loggedIn) { avatarRow.knoedel.setCircleColor(Color.GREEN); avatarRow.onlineImage.setImageResource(R.drawable.online); } else { avatarRow.knoedel.setCircleColor(Color.RED); avatarRow.onlineImage.setImageResource(R.drawable.offline); } avatarRow.setDropDownSelectionWithoutAction(global.puller.storedData.avatarDropdownSelection); } } @Override protected void onResume() { super.onResume(); performFilter(); checkForLogIn(); navigation.getMenu().getItem(1).setChecked(true); System.out.println("XXXXX4"); } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); INNTELApplication application = (INNTELApplication) getApplication(); global = application.global; setStatusBarColorNow(global.puller.storedData.carrierCi.foreGround); setContentView(R.layout.activity_history); BottomNavigationView.OnNavigationItemSelectedListener listener = new BottomNavigationListener(this, global, this); navigation = (BottomNavigationView) findViewById(R.id.navigation); Utilities.createMenu(navigation, global); ColorStateList iconTintList = ColorStateList.valueOf(Color.parseColor(global.puller.storedData.carrierCi.foreGround)); int[][] states = new int[][]{ new int[]{android.R.attr.state_checked}, // checked new int[]{-android.R.attr.state_checked} // unchecked }; int[] colors = new int[]{ Color.parseColor(global.puller.storedData.carrierCi.foreGround), // for checked state Color.GRAY // for unchecked state }; ColorStateList colorStateList = new ColorStateList(states, colors); navigation.setItemIconTintList(colorStateList); navigation.setItemTextColor(colorStateList); navigation.setOnNavigationItemSelectedListener(listener); progressDialog = new LoadingScreen(this, global); progressDialog.show(); buildGUI(); } public void buildGUI() { LinearLayout fixedUpperStack = findViewById(R.id.fixedUpperStack); fixedUpperStack.setGravity(Gravity.CENTER); fixedUpperStack.setClipChildren(false); addVerticalSpacer(fixedUpperStack, 8, this); fixedUpperStack.setBackgroundColor(Color.parseColor(global.puller.storedData.carrierCi.foreGround)); avatarRow = new AvatarRow(this, this); fixedUpperStack.addView(avatarRow); addVerticalSpacer(fixedUpperStack, 8, this); LinearLayout fixedLowerStack = findViewById(R.id.fixedLowerStack); fixedLowerStack.setOrientation(LinearLayout.VERTICAL); fixedLowerStack.setBackgroundColor(Color.parseColor(global.puller.storedData.carrierCi.backGround)); addVerticalSpacer(fixedLowerStack, 8, this); LinearLayout searchRow = new LinearLayout(this); searchRow.setOrientation(LinearLayout.HORIZONTAL); addHorizontalSpacer(searchRow, 20, this); EditText searchText = new EditText(this); searchText.setLayoutParams(new LinearLayout.LayoutParams(global.appleW(375 - (20 + 8 + 35 + 8)), LinearLayout.LayoutParams.WRAP_CONTENT)); searchText.setHint(global.getTranslation("callList")); searchText.setHintTextColor(Color.GRAY); searchText.setTextSize(TypedValue.COMPLEX_UNIT_PX, global.appleH(20)); searchText.setTextAlignment(View.TEXT_ALIGNMENT_TEXT_START); searchText.setTextColor(global.textColor); searchText.setBackgroundColor(Color.parseColor(global.puller.storedData.carrierCi.backGround)); searchText.setSingleLine(true); searchText.setSelectAllOnFocus(true); searchText.setEnabled(false); searchText.setFocusable(false); searchText.setFocusableInTouchMode(false); searchText.setCursorVisible(false); searchRow.addView(searchText); addHorizontalSpacer(searchRow, 8, this); addHorizontalSpacer(searchRow, 8, this); fixedLowerStack.addView(searchRow); LinearLayout searchButRow = new LinearLayout(this); searchButRow.setOrientation(LinearLayout.HORIZONTAL); addHorizontalSpacer(searchButRow, 12 + 3, this); View.OnClickListener firstButListener = new View.OnClickListener() { @Override public void onClick(View v) { String filteredBy = ""; System.out.println("firstButPressed."); if (firstButBack.isSelected()) { firstButBack.unSelect(); } else { firstButBack.select(); secondButBack.unSelect(); thirdButBack.unSelect(); filteredBy = "outgoing"; } performFilter(filteredBy); } }; int buttonHeight = 35; firstButBack = new FilterButton(global.getTranslation("outgoing"), firstButListener, this, (375 - 24) / 3, buttonHeight); searchButRow.addView(firstButBack.butBack); View.OnClickListener secondButListener = new View.OnClickListener() { @Override public void onClick(View v) { System.out.println("secondButPressed."); String filteredBy = ""; if (secondButBack.isSelected()) { secondButBack.unSelect(); } else { firstButBack.unSelect(); secondButBack.select(); thirdButBack.unSelect(); filteredBy = "incoming"; } performFilter(filteredBy); } }; secondButBack = new FilterButton(global.getTranslation("incoming"), secondButListener, this, (375 - 24) / 3, buttonHeight); searchButRow.addView(secondButBack.butBack); View.OnClickListener thirdButListener = new View.OnClickListener() { @Override public void onClick(View v) { System.out.println("thirdButPressed."); String filteredBy = ""; if (thirdButBack.isSelected()) { thirdButBack.unSelect(); } else { firstButBack.unSelect(); secondButBack.unSelect(); thirdButBack.select(); filteredBy = "missed"; } performFilter(filteredBy); } }; thirdButBack = new FilterButton(global.getTranslation("missed"), thirdButListener, this, (375 - 24) / 3, buttonHeight); searchButRow.addView(thirdButBack.butBack); addHorizontalSpacer(searchButRow, 12 + 3, this); fixedLowerStack.addView(searchButRow); addVerticalSpacer(fixedLowerStack, 8, this); findViewById(R.id.scrollview).setBackgroundColor(Color.parseColor(global.puller.storedData.carrierCi.backGround)); theStack = findViewById(R.id.itemstack); theStack.setGravity(Gravity.CENTER); theStack.setClipChildren(false); performFilter(""); hideLoadingScreenIfNothingLeftToWaitFor(); keepOnDoing = new Handler(); keepOnDoing.postDelayed(mCheckForLoginRunnable, 2000); } public LinearLayout addPhoneRow(LinearLayout theStack, CallEntity call) { View hairLine = new View(this); hairLine.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 1)); hairLine.setBackgroundColor(Color.LTGRAY); theStack.addView(hairLine); LinearLayout phoneRow = new LinearLayout(this); phoneRow.setOrientation(LinearLayout.HORIZONTAL); phoneRow.setVerticalGravity(Gravity.CENTER); phoneRow.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, global.appleH(45))); addHorizontalSpacer(phoneRow, 4, this); BetterImageView outgoingIncoming = new BetterImageView(this); LinearLayout.LayoutParams outgoingIncomingParams = new LinearLayout.LayoutParams(global.appleW(15), LinearLayout.LayoutParams.WRAP_CONTENT); outgoingIncoming.setLayoutParams(outgoingIncomingParams); outgoingIncoming.setScaleType(ImageView.ScaleType.CENTER_INSIDE); outgoingIncoming.setAdjustViewBounds(true); if (call.outgoing) outgoingIncoming.setImageResource(R.drawable.outgoing); else outgoingIncoming.setImageResource(R.drawable.incoming); phoneRow.addView(outgoingIncoming); addHorizontalSpacer(phoneRow, 4, this); TextView aLabel = new TextView(this); User user = call.user; String klammer = ""; if (user.extension == null) { if (user.mobile.length() > 7) { if (user.mobile.startsWith("+")) klammer = " (" + user.mobile.substring(0, 6) + ".." + user.mobile.substring(user.mobile.length() - 4) + ")"; else klammer = " (" + user.mobile.substring(0, 4) + ".." + user.mobile.substring(user.mobile.length() - 4) + ")"; } else { klammer = " (" + user.mobile + ")"; } } else klammer = " (" + user.extension + ")"; String theText = user.firstname + " " + user.lastname + klammer; theText = Utilities.removeLeadingSpaces(theText); aLabel.setText(theText); aLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX, global.appleH(20)); aLabel.setTextAlignment(View.TEXT_ALIGNMENT_TEXT_START); //328 aLabel.setLayoutParams(new LinearLayout.LayoutParams(global.appleW(308), LinearLayout.LayoutParams.WRAP_CONTENT)); aLabel.setTextColor(global.textColor); //aLabel.setBackgroundColor(Color.RED); if (!call.success) aLabel.setTextColor(Color.RED); phoneRow.addView(aLabel); FrameLayout outerContainer = new FrameLayout(this); LinearLayout.LayoutParams outerContainerParams = new LinearLayout.LayoutParams( global.appleW(40), // Width same as the ImageView LinearLayout.LayoutParams.MATCH_PARENT // Height matches the stack row ); //outerContainer.setBackgroundColor(Color.BLUE); outerContainer.setLayoutParams(outerContainerParams); // Center the ImageView inside the FrameLayout BetterImageView infoBut = new BetterImageView(this); FrameLayout.LayoutParams infoButParams = new FrameLayout.LayoutParams( global.appleW(20), // Image width global.appleW(20), // Image height (you can adjust this as needed) Gravity.END | Gravity.CENTER_VERTICAL ); infoBut.setLayoutParams(infoButParams); infoBut.setScaleType(ImageView.ScaleType.CENTER_INSIDE); infoBut.setAdjustViewBounds(true); infoBut.setImageResource(R.drawable.exclamationmark); // Add the ImageView to the FrameLayout outerContainer.addView(infoBut); /* ImageView infoBut = new ImageView(this); LinearLayout.LayoutParams infoButParams = new LinearLayout.LayoutParams(global.appleW(20), LinearLayout.LayoutParams.WRAP_CONTENT); infoBut.setLayoutParams(infoButParams); infoBut.setScaleType(ImageView.ScaleType.CENTER_INSIDE); infoBut.setAdjustViewBounds(true); infoBut.setImageResource(R.drawable.exclamationmark); infoBut.setClickable(true); infoBut.setFocusable(true); infoBut.setBackgroundColor(Color.BLUE); */ View.OnClickListener infoButListener = new View.OnClickListener() { @Override public void onClick(View v) { System.out.println("infoButPressed: " + call.user.mobile + " " + call.duration); String message = global.getTranslation("Duration:") + " " + call.duration + " " + global.getTranslation("Date:") + " " + Utilities.humanReadableDate(call.time); createInfoDialog("info", message); } }; outerContainer.setOnClickListener(infoButListener); phoneRow.addView(outerContainer); addHorizontalSpacer(phoneRow, 4, this); View.OnClickListener phoneRowListener = new View.OnClickListener() { @Override public void onClick(View v) { int[] locInWindow = new int[2]; phoneRow.getLocationOnScreen(locInWindow); System.out.println("phoneRowPressed:" + locInWindow[0] + " " + locInWindow[1]); contactTapped(user); } }; aLabel.setOnClickListener(phoneRowListener); theStack.addView(phoneRow); return phoneRow; } public void contactTapped(User user) { global.puller.storedData.callEntity = new CallEntity(global.puller.storedData.callList.size() + "", user, true, new Date()); global.puller.storedData.callList.add(global.puller.storedData.callEntity); global.puller.saveStoredData(); Intent newIntent = new Intent(History.this, CallingScreen.class); newIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); this.startActivity(newIntent); } public void performFilter() { performFilter(lastFilteredBy); } public void performFilter(String filter) { lastFilteredBy = filter; theStack.removeAllViews(); for (int i = global.puller.storedData.callList.size() - 1; i > -1; i--) { CallEntity act = global.puller.storedData.callList.get(i); if ("".equals(filter)) { LinearLayout theRow = addPhoneRow(theStack, act); } else { if ("outgoing".equals(filter) && act.outgoing) { LinearLayout theRow = addPhoneRow(theStack, act); } if ("incoming".equals(filter) && !act.outgoing) { LinearLayout theRow = addPhoneRow(theStack, act); } if ("missed".equals(filter) && !act.success) { LinearLayout theRow = addPhoneRow(theStack, act); } } } } } package at.inntelco.INNTEL.home; import android.content.DialogInterface; import android.content.Intent; import android.content.res.ColorStateList; import android.graphics.Color; import android.graphics.PorterDuff; import android.net.Uri; import android.os.Bundle; import android.os.Handler; import android.util.TypedValue; import android.view.Gravity; import android.view.View; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import androidx.appcompat.app.AlertDialog; import com.google.android.material.bottomnavigation.BottomNavigationView; import at.inntelco.INNTEL.BetterActivity; import at.inntelco.INNTEL.BetterImageView; import at.inntelco.INNTEL.BuildConfig; import at.inntelco.INNTEL.Expander; import at.inntelco.INNTEL.LoadingScreen; import at.inntelco.INNTEL.MainActivity; import at.inntelco.INNTEL.INNTELApplication; import at.inntelco.INNTEL.R; import at.inntelco.INNTEL.Utilities; public class Settings extends BetterActivity { public LinearLayout theStack; public AvatarRow avatarRow; private Runnable mCheckForLoginRunnable = new Runnable() { @Override public void run() { checkForLogIn(); keepOnDoing.postDelayed(this, 2000); } }; public boolean keepchecking = true; public Handler keepOnDoing; private void checkForLogIn() { if (keepchecking && avatarRow != null) { if (INNTELApplication.coreContext.loggedIn) { avatarRow.knoedel.setCircleColor(Color.GREEN); avatarRow.onlineImage.setImageResource(R.drawable.online); } else { avatarRow.knoedel.setCircleColor(Color.RED); avatarRow.onlineImage.setImageResource(R.drawable.offline); } avatarRow.setDropDownSelectionWithoutAction(global.puller.storedData.avatarDropdownSelection); } } @Override protected void onResume() { super.onResume(); keepchecking = true; checkForLogIn(); navigation.getMenu().getItem(3).setChecked(true); } @Override protected void onCreate(Bundle savedInstanceState) { INNTELApplication application = (INNTELApplication) getApplication(); global = application.global; setStatusBarColorNow(global.puller.storedData.carrierCi.foreGround); super.onCreate(savedInstanceState); setContentView(R.layout.activity_history); BottomNavigationView.OnNavigationItemSelectedListener listener = new BottomNavigationListener(this, global, this); navigation = (BottomNavigationView) findViewById(R.id.navigation); Utilities.createMenu(navigation, global); ColorStateList iconTintList = ColorStateList.valueOf(Color.parseColor(global.puller.storedData.carrierCi.foreGround)); int[][] states = new int[][]{ new int[]{android.R.attr.state_checked}, // checked new int[]{-android.R.attr.state_checked} // unchecked }; int[] colors = new int[]{ Color.parseColor(global.puller.storedData.carrierCi.foreGround), // for checked state Color.GRAY // for unchecked state }; ColorStateList colorStateList = new ColorStateList(states, colors); navigation.setItemIconTintList(colorStateList); navigation.setItemTextColor(colorStateList); navigation.setOnNavigationItemSelectedListener(listener); progressDialog = new LoadingScreen(this, global); progressDialog.show(); buildGUI(); } public void buildGUI() { LinearLayout fixedUpperStack = findViewById(R.id.fixedUpperStack); fixedUpperStack.setGravity(Gravity.CENTER); fixedUpperStack.setClipChildren(false); addVerticalSpacer(fixedUpperStack, 8, this); fixedUpperStack.setBackgroundColor(Color.parseColor(global.puller.storedData.carrierCi.foreGround)); avatarRow = new AvatarRow(this, this); fixedUpperStack.addView(avatarRow); addVerticalSpacer(fixedUpperStack, 8, this); LinearLayout fixedLowerStack = findViewById(R.id.fixedLowerStack); fixedLowerStack.setOrientation(LinearLayout.VERTICAL); fixedLowerStack.setBackgroundColor(Color.parseColor(global.puller.storedData.carrierCi.backGround)); findViewById(R.id.scrollview).setBackgroundColor(Color.parseColor(global.puller.storedData.carrierCi.backGround)); theStack = findViewById(R.id.itemstack); theStack.setGravity(Gravity.CENTER); theStack.setClipChildren(false); addVerticalSpacer(theStack, 16, this); LinearLayout headRow = new LinearLayout(this); headRow.setOrientation(LinearLayout.HORIZONTAL); theStack.addView(headRow); addHorizontalSpacer(headRow, 12, this); TextView aLabel = new TextView(this); aLabel.setText(global.getTranslation("settings")); aLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX, global.appleH(25)); aLabel.setTextAlignment(View.TEXT_ALIGNMENT_TEXT_START); aLabel.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); aLabel.setTextColor(global.textColor); headRow.addView(aLabel); Expander showNumberRow = new Expander(this, this, global.getTranslation("showNumber")); LinearLayout showNumberContentRow = new LinearLayout(this); showNumberContentRow.setOrientation(LinearLayout.HORIZONTAL); addHorizontalSpacer(showNumberContentRow, 12, this); TextView bLabel = new TextView(this); bLabel.setText(global.puller.storedData.user.mobile); bLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX, global.appleH(18)); bLabel.setTextAlignment(View.TEXT_ALIGNMENT_TEXT_START); bLabel.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); bLabel.setTextColor(global.textColor); showNumberContentRow.addView(bLabel); View.OnClickListener phoneRowListener = new View.OnClickListener() { @Override public void onClick(View v) { if (showNumberContentRow.getVisibility() == View.GONE) showNumberContentRow.setVisibility(View.VISIBLE); else showNumberContentRow.setVisibility(View.GONE); showNumberRow.toggleOpenClose(); } }; showNumberRow.setOnClickListener(phoneRowListener); theStack.addView(showNumberRow); showNumberContentRow.setVisibility(View.GONE); theStack.addView(showNumberContentRow); addZierZeile(theStack); Expander logInAnotherRow = new Expander(this, this, global.getTranslation("logInWithAnotherNumber")); View.OnClickListener logInAnotherListener = new View.OnClickListener() { @Override public void onClick(View v) { reset(); } }; logInAnotherRow.setOnClickListener(logInAnotherListener); theStack.addView(logInAnotherRow); addZierZeile(theStack); Expander appVersionRow = new Expander(this, this, global.getTranslation("appVersion")); LinearLayout appVersionContentRow = new LinearLayout(this); appVersionContentRow.setOrientation(LinearLayout.HORIZONTAL); addHorizontalSpacer(appVersionContentRow, 12, this); TextView cLabel = new TextView(this); cLabel.setText("" + BuildConfig.VERSION_NAME); cLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX, global.appleH(18)); cLabel.setTextAlignment(View.TEXT_ALIGNMENT_TEXT_START); cLabel.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); cLabel.setTextColor(global.textColor); appVersionContentRow.addView(cLabel); View.OnClickListener appVersionRowListener = new View.OnClickListener() { @Override public void onClick(View v) { if (appVersionContentRow.getVisibility() == View.GONE) appVersionContentRow.setVisibility(View.VISIBLE); else appVersionContentRow.setVisibility(View.GONE); appVersionRow.toggleOpenClose(); } }; appVersionRow.setOnClickListener(appVersionRowListener); theStack.addView(appVersionRow); appVersionContentRow.setVisibility(View.GONE); theStack.addView(appVersionContentRow); addZierZeile(theStack); Expander openSourceLizenzenRow = new Expander(this, this, global.getTranslation("Open-Source-Lizenzen")); LinearLayout openSourceLizenzenContentRow = new LinearLayout(this); openSourceLizenzenContentRow.setOrientation(LinearLayout.HORIZONTAL); addHorizontalSpacer(openSourceLizenzenContentRow, 12, this); TextView openSourceLabel = new TextView(this); openSourceLabel.setText(global.getTranslation("GPLv3 (Weblink)")); openSourceLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX, global.appleH(18)); openSourceLabel.setTextAlignment(View.TEXT_ALIGNMENT_TEXT_START); openSourceLabel.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); openSourceLabel.setTextColor(global.textColor); openSourceLizenzenContentRow.addView(openSourceLabel); View.OnClickListener openSourceRowListener = new View.OnClickListener() { @Override public void onClick(View v) { if (openSourceLizenzenContentRow.getVisibility() == View.GONE) openSourceLizenzenContentRow.setVisibility(View.VISIBLE); else openSourceLizenzenContentRow.setVisibility(View.GONE); openSourceLizenzenRow.toggleOpenClose(); } }; openSourceLizenzenRow.setOnClickListener(openSourceRowListener); openSourceLizenzenContentRow.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(global.getTranslation("XXX"))); v.getContext().startActivity(browserIntent); } }); theStack.addView(openSourceLizenzenRow); openSourceLizenzenContentRow.setVisibility(View.GONE); theStack.addView(openSourceLizenzenContentRow); addZierZeile(theStack); Expander impressumRow = new Expander(this, this, global.getTranslation("imprint")); LinearLayout impressumContentRow = new LinearLayout(this); impressumContentRow.setOrientation(LinearLayout.HORIZONTAL); addHorizontalSpacer(impressumContentRow, 12, this); TextView dLabel = new TextView(this); dLabel.setText(global.getTranslation("imprintContent")); dLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX, global.appleH(18)); dLabel.setTextAlignment(View.TEXT_ALIGNMENT_TEXT_START); dLabel.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); dLabel.setTextColor(global.textColor); impressumContentRow.addView(dLabel); View.OnClickListener impressumRowListener = new View.OnClickListener() { @Override public void onClick(View v) { if (impressumContentRow.getVisibility() == View.GONE) impressumContentRow.setVisibility(View.VISIBLE); else impressumContentRow.setVisibility(View.GONE); impressumRow.toggleOpenClose(); } }; impressumRow.setOnClickListener(impressumRowListener); theStack.addView(impressumRow); impressumContentRow.setVisibility(View.GONE); theStack.addView(impressumContentRow); addZierZeile(theStack); Expander dSRow = new Expander(this, this, global.getTranslation("Datenschutz")); LinearLayout dsContentRow = new LinearLayout(this); dsContentRow.setOrientation(LinearLayout.HORIZONTAL); addHorizontalSpacer(dsContentRow, 12, this); TextView dsLabel = new TextView(this); dsLabel.setText(global.getTranslation("Datenschutz (Weblink)")); dsLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX, global.appleH(18)); dsLabel.setTextAlignment(View.TEXT_ALIGNMENT_TEXT_START); dsLabel.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); dsLabel.setTextColor(global.textColor); dsContentRow.addView(dsLabel); View.OnClickListener dsRowListener = new View.OnClickListener() { @Override public void onClick(View v) { if (dsContentRow.getVisibility() == View.GONE) dsContentRow.setVisibility(View.VISIBLE); else dsContentRow.setVisibility(View.GONE); dSRow.toggleOpenClose(); } }; dSRow.setOnClickListener(dsRowListener); dsContentRow.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(global.getTranslation("XXX"))); v.getContext().startActivity(browserIntent); } }); theStack.addView(dSRow); dsContentRow.setVisibility(View.GONE); theStack.addView(dsContentRow); addZierZeile(theStack); Expander agbRow = new Expander(this, this, global.getTranslation("AGB")); LinearLayout agbContentRow = new LinearLayout(this); agbContentRow.setOrientation(LinearLayout.HORIZONTAL); addHorizontalSpacer(agbContentRow, 12, this); TextView agbLabel = new TextView(this); agbLabel.setText(global.getTranslation("AGB (Weblink)")); agbLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX, global.appleH(18)); agbLabel.setTextAlignment(View.TEXT_ALIGNMENT_TEXT_START); agbLabel.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); agbLabel.setTextColor(global.textColor); agbContentRow.addView(agbLabel); View.OnClickListener agbRowListener = new View.OnClickListener() { @Override public void onClick(View v) { if (agbContentRow.getVisibility() == View.GONE) agbContentRow.setVisibility(View.VISIBLE); else agbContentRow.setVisibility(View.GONE); agbRow.toggleOpenClose(); } }; agbRow.setOnClickListener(agbRowListener); agbContentRow.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(global.getTranslation("XXX"))); v.getContext().startActivity(browserIntent); } }); theStack.addView(agbRow); agbContentRow.setVisibility(View.GONE); theStack.addView(agbContentRow); addZierZeile(theStack); hideLoadingScreenIfNothingLeftToWaitFor(); keepOnDoing = new Handler(); keepOnDoing.postDelayed(mCheckForLoginRunnable, 2000); } public void performReset(){ System.out.println("reset..."); keepchecking=false; global.puller.resetAll(); Intent newIntent = new Intent(this, MainActivity.class); newIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(newIntent); finish(); } public void reset() { String msg=global.getTranslation("Sind Sie sicher, dass Sie sich abmelden möchten? Ihre Anruflisten werden gelöscht."); AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this); alertBuilder.setMessage(msg); alertBuilder.setPositiveButton( global.getTranslation("OK"), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); performReset(); } }); alertBuilder.setNegativeButton( global.getTranslation("Abbrechen"), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alertDialog = alertBuilder.create(); alertDialog.setCancelable(false); alertDialog.setCanceledOnTouchOutside(false); alertDialog.show(); } public void addZierZeile(LinearLayout stack) { View hairLine = new View(this); hairLine.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 1)); hairLine.setBackgroundColor(Color.LTGRAY); stack.addView(hairLine); } public LinearLayout addExtendRow(LinearLayout stack, String caption) { LinearLayout phoneRow = new LinearLayout(this); phoneRow.setOrientation(LinearLayout.HORIZONTAL); phoneRow.setVerticalGravity(Gravity.CENTER); phoneRow.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, global.appleH(55))); addHorizontalSpacer(phoneRow, 12, this); TextView aLabel = new TextView(this); aLabel.setText(caption); aLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX, global.appleH(20)); aLabel.setTextAlignment(View.TEXT_ALIGNMENT_TEXT_START); aLabel.setLayoutParams(new LinearLayout.LayoutParams(global.appleW(332), LinearLayout.LayoutParams.WRAP_CONTENT)); aLabel.setTextColor(global.textColor); phoneRow.addView(aLabel); BetterImageView infoBut = new BetterImageView(this); LinearLayout.LayoutParams infoButParams = new LinearLayout.LayoutParams(global.appleW(20), LinearLayout.LayoutParams.WRAP_CONTENT); infoBut.setLayoutParams(infoButParams); infoBut.setScaleType(ImageView.ScaleType.CENTER_INSIDE); infoBut.setAdjustViewBounds(true); infoBut.setImageResource(R.drawable.arrowup); infoBut.setBackgroundColor(Color.parseColor(global.puller.storedData.carrierCi.backGround)); infoBut.setColorFilter(Color.parseColor(global.puller.storedData.carrierCi.foreGround), PorterDuff.Mode.SRC_IN); phoneRow.addView(infoBut); stack.addView(phoneRow); return phoneRow; } } package at.inntelco.INNTEL.login; import android.content.Intent; import android.graphics.Color; import android.os.AsyncTask; import android.os.Bundle; import android.text.InputType; import android.util.TypedValue; import android.view.Gravity; import android.view.View; import android.widget.EditText; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ScrollView; import android.widget.TextView; import com.google.gson.Gson; import com.google.gson.stream.JsonReader; import at.inntelco.INNTEL.BetterActivity; import at.inntelco.INNTEL.BetterImageView; import at.inntelco.INNTEL.LoadingScreen; import at.inntelco.INNTEL.INNTELApplication; import at.inntelco.INNTEL.R; import at.inntelco.INNTEL.data.AuthInfo; import java.io.StringReader; import java.util.LinkedHashMap; public class Authentication extends BetterActivity { public ScrollView itemBack; TextView errMessage; @Override protected void onCreate(Bundle savedInstanceState) { INNTELApplication application = (INNTELApplication) getApplication(); global = application.global; super.onCreate(savedInstanceState); setStatusBarColorNow(global.puller.storedData.carrierCi.backGround); setContentView(R.layout.activity_login); progressDialog = new LoadingScreen(this, global); progressDialog.show(); buildGUI(); } public void buildGUI() { itemBack = findViewById(R.id.scrollview); itemBack.setBackgroundColor(Color.parseColor(global.puller.storedData.carrierCi.backGround)); LinearLayout theStack = findViewById(R.id.itemstack); theStack.setGravity(Gravity.CENTER); theStack.setClipChildren(false); addVerticalSpacer(theStack, 75, this); BetterImageView headerImage = new BetterImageView(this); LinearLayout.LayoutParams paramsX = new LinearLayout.LayoutParams(global.appleW(180), LinearLayout.LayoutParams.WRAP_CONTENT); headerImage.setLayoutParams(paramsX); headerImage.setScaleType(ImageView.ScaleType.CENTER_INSIDE); headerImage.setAdjustViewBounds(true); String remoteLogo = global.puller.storedData.carrierCi.contenturl +"carrier/"+ global.puller.storedData.carrierCi.id + "/logo.png"; global.puller.loadImage(headerImage, remoteLogo, null,this); theStack.addView(headerImage); addVerticalSpacer(theStack, 45, this); TextView headLine = new TextView(this); headLine.setText(global.getTranslation("twofactorauthentification")); headLine.setTextSize(TypedValue.COMPLEX_UNIT_PX, global.appleH(22)); headLine.setTextAlignment(View.TEXT_ALIGNMENT_CENTER); headLine.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); headLine.setTextColor(global.textColor); theStack.addView(headLine); errMessage = new TextView(this); errMessage.setText(""); errMessage.setTextSize(TypedValue.COMPLEX_UNIT_PX, global.appleH(22)); errMessage.setTextAlignment(View.TEXT_ALIGNMENT_CENTER); errMessage.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); errMessage.setTextColor(Color.RED); theStack.addView(errMessage); addVerticalSpacer(theStack, 40, this); EditText mobilenumberfield = Login.createInputText(global.getTranslation("mobilenrxxx"), this); mobilenumberfield.setInputType(InputType.TYPE_CLASS_PHONE); theStack.addView(mobilenumberfield); addVerticalSpacer(theStack, 20, this); View.OnClickListener listener = new View.OnClickListener() { @Override public void onClick(View v) { String theInput = mobilenumberfield.getText().toString(); boolean err=false; if(theInput.length()<4) err=true; if(!err) { if (theInput.startsWith("++") || theInput.startsWith("00")) { global.puller.storedData.vorWahl = theInput.substring(2, 4); } else if (theInput.startsWith("+")) { global.puller.storedData.vorWahl = theInput.substring(1, 3); } else err = true; } if(err){ errMessage.setText("\n"+global.getTranslation("Please enter full number including your country prefix (e.g. 0043, +43, ++43).")); }else { System.out.println("vorwahl:" + global.puller.storedData.vorWahl); progressDialog.show(); sendCode(mobilenumberfield.getText().toString()); } } }; Login.addButton(global.getTranslation("sendcode"),listener,theStack,this); } public static void sendCode(String mobileNr, TextView errMessage, BetterActivity mother){ if(mother.checkInternet()) new APITask(mother, errMessage).execute(mobileNr); else mother.createErrorDialog("No Internet connection.", () -> sendCode(mobileNr, errMessage, mother)); } public void sendCode(String mobileNr) { new APITask(this, errMessage).execute(mobileNr); } private static class APITask extends AsyncTask { BetterActivity mother; TextView errMessage; public APITask(BetterActivity mother,TextView errMessage) { this.mother = mother; this.errMessage=errMessage; } protected String doInBackground(String... args) { String ret = ""; try { String mobileNr = args[0]; LinkedHashMap params = new LinkedHashMap(); params.put("mobilenumber", mobileNr); ret = mother.global.puller.webserviceCall("getmobiletoken", params, true,mother.global.puller.storedData.loginInfo.apikey, null); System.out.println(ret); String json = ret; Gson gson = new Gson(); JsonReader reader = new JsonReader(new StringReader(json)); reader.setLenient(true); AuthInfo auth = gson.fromJson(reader, AuthInfo.class); mother.global.puller.storedData.loginInfo.authMobileNumber=auth.mobilenumbersyntaxcorrected; mother.global.puller.storedData.loginInfo.dialoguuid=auth.dialoguuid; if(auth.result.equals("tokenSentSuccessfully")) ret = "alldone"; else ret=auth.result; } catch (Exception e) { e.printStackTrace(); ret="apiError"; } return ret; } protected void onPostExecute(String result) { if (result.equals("alldone")) { mother.global.puller.saveStoredData(); Intent newIntent = new Intent(mother, Verification.class); mother.startActivity(newIntent); } else { if(result.equals("moreThanThreeTokensInLastTenMinutes")) errMessage.setText("\n"+mother.global.getTranslation("toomanytokens")); if(result.equals("mobileNumberError")) errMessage.setText("\n"+mother.global.getTranslation("mobilenumbererror")); if(result.equals("apiError")) errMessage.setText("\n"+mother.global.getTranslation("apierror")); mother.progressDialog.dismiss(); } } } } package at.inntelco.INNTEL.login; import android.Manifest; import android.content.Intent; import android.content.pm.PackageManager; import android.graphics.Color; import android.graphics.drawable.GradientDrawable; import android.os.AsyncTask; import android.os.Bundle; import androidx.appcompat.app.AppCompatActivity; import androidx.core.app.ActivityCompat; import android.text.InputType; import android.util.TypedValue; import android.view.Gravity; import android.view.View; import android.widget.EditText; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ScrollView; import android.widget.TextView; import com.google.gson.Gson; import com.google.gson.stream.JsonReader; import at.inntelco.INNTEL.BetterActivity; import at.inntelco.INNTEL.BetterImageView; import at.inntelco.INNTEL.LoadingScreen; import at.inntelco.INNTEL.INNTELApplication; import at.inntelco.INNTEL.R; import at.inntelco.INNTEL.data.CarrierCi; import at.inntelco.INNTEL.data.LoginInfo; import at.inntelco.INNTEL.data.WordDictionary; import java.io.StringReader; import java.util.HashMap; import java.util.LinkedHashMap; public class Login extends BetterActivity { public ScrollView itemBack; TextView errMessage; @Override protected void onCreate(Bundle savedInstanceState) { INNTELApplication application = (INNTELApplication) getApplication(); global = application.global; super.onCreate(savedInstanceState); setStatusBarColorNow(global.puller.storedData.carrierCi.backGround); setContentView(R.layout.activity_login); progressDialog = new LoadingScreen(this, global); progressDialog.show(); new LoadingTask().execute(); buildGUI(); } public static void addButton(String caption, View.OnClickListener listener, LinearLayout stack, BetterActivity mother) { GradientDrawable drawableButton = new GradientDrawable(); drawableButton.setShape(GradientDrawable.RECTANGLE); drawableButton.setColor(Color.parseColor(mother.global.puller.storedData.carrierCi.foreGround)); LinearLayout loginBut = new LinearLayout(mother); loginBut.setLayoutParams(new LinearLayout.LayoutParams(mother.global.appleW(281), mother.global.appleH(50))); loginBut.setVerticalGravity(Gravity.CENTER); loginBut.setBackground(drawableButton); TextView loginButCaption = new TextView(mother); loginButCaption.setText(caption); loginButCaption.setTextSize(TypedValue.COMPLEX_UNIT_PX, mother.global.appleH(22)); loginButCaption.setTextAlignment(View.TEXT_ALIGNMENT_CENTER); loginButCaption.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); loginButCaption.setTextColor(Color.parseColor(mother.global.puller.storedData.carrierCi.backGround)); loginBut.addView(loginButCaption); loginBut.setOnClickListener(listener); stack.addView(loginBut); } public static EditText createInputText(String text, BetterActivity mother) { GradientDrawable shape = new GradientDrawable(); shape.setShape(GradientDrawable.RECTANGLE); shape.setColor(Color.WHITE); shape.setStroke(3, Color.parseColor(mother.global.puller.storedData.carrierCi.foreGround)); EditText inputField = new EditText(mother); inputField.setLayoutParams(new LinearLayout.LayoutParams(mother.global.appleW(281), LinearLayout.LayoutParams.MATCH_PARENT)); inputField.setHint(text); inputField.setHintTextColor(Color.GRAY); inputField.setTextSize(TypedValue.COMPLEX_UNIT_PX, mother.global.appleH(18)); inputField.setTextAlignment(View.TEXT_ALIGNMENT_TEXT_START); inputField.setTextColor(mother.global.textColor); inputField.setBackgroundColor(Color.WHITE); inputField.setSingleLine(true); inputField.setBackground(shape); inputField.setPadding(30, 15, 30, 15); return inputField; } public void buildGUI() { itemBack = findViewById(R.id.scrollview); itemBack.setBackgroundColor(Color.parseColor(global.puller.storedData.carrierCi.backGround)); LinearLayout theStack = findViewById(R.id.itemstack); theStack.setGravity(Gravity.CENTER); theStack.setClipChildren(false); addVerticalSpacer(theStack, 75, this); BetterImageView headerImage = new BetterImageView(this); LinearLayout.LayoutParams paramsX = new LinearLayout.LayoutParams(global.appleW(180), LinearLayout.LayoutParams.WRAP_CONTENT); headerImage.setLayoutParams(paramsX); headerImage.setScaleType(ImageView.ScaleType.CENTER_INSIDE); headerImage.setAdjustViewBounds(true); String remoteLogo = global.puller.storedData.carrierCi.contenturl + "carrier/" + global.puller.storedData.carrierCi.id + "/logo.png"; global.puller.loadImage(headerImage, remoteLogo, null, this); theStack.addView(headerImage); addVerticalSpacer(theStack, 45, this); TextView headLine = new TextView(this); headLine.setText(global.getTranslation("welcomemessage")); headLine.setTextSize(TypedValue.COMPLEX_UNIT_PX, global.appleH(22)); headLine.setTextAlignment(View.TEXT_ALIGNMENT_CENTER); headLine.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); headLine.setTextColor(global.textColor); theStack.addView(headLine); errMessage = new TextView(this); errMessage.setText(""); errMessage.setTextSize(TypedValue.COMPLEX_UNIT_PX, global.appleH(22)); errMessage.setTextAlignment(View.TEXT_ALIGNMENT_CENTER); errMessage.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); errMessage.setTextColor(Color.RED); theStack.addView(errMessage); addVerticalSpacer(theStack, 40, this); EditText serverEdit = createInputText(global.getTranslation("server"), this); theStack.addView(serverEdit); addVerticalSpacer(theStack, 20, this); EditText usernameEdit = createInputText(global.getTranslation("username"), this); theStack.addView(usernameEdit); addVerticalSpacer(theStack, 20, this); EditText passwordEdit = createInputText(global.getTranslation("password"), this); theStack.addView(passwordEdit); addVerticalSpacer(theStack, 20, this); View.OnClickListener listener = new View.OnClickListener() { @Override public void onClick(View v) { progressDialog.show(); registerUser(serverEdit.getText().toString(), usernameEdit.getText().toString(), passwordEdit.getText().toString()); } }; addButton(global.getTranslation("signin"), listener, theStack, this); } public void registerUser(String carrierServer, String username, String password) { if (checkInternet()) new APITask(this).execute(carrierServer, username, password); else createErrorDialog("No Internet connection.", () -> registerUser(carrierServer, username, password)); } private class APITask extends AsyncTask { AppCompatActivity mother; public APITask(AppCompatActivity mother) { this.mother = mother; } protected String doInBackground(String... args) { String ret = ""; try { String theServer = args[0]; if (theServer.contains("/")) { String carrierCiId = theServer.split("/")[1]; theServer = theServer.split("/")[0]; try { LinkedHashMap params = new LinkedHashMap(); params.put("carrierciid", carrierCiId); ret = global.puller.webserviceCall("getcarrierci", params, true, null, null); System.out.println(ret); String json = ret; Gson gson = new Gson(); JsonReader reader = new JsonReader(new StringReader(json)); reader.setLenient(true); global.puller.storedData.carrierCi = gson.fromJson(reader, CarrierCi.class); global.puller.storedData.carrierCi.id = carrierCiId; String languageId = global.puller.storedData.carrierCi.languageId; params = new LinkedHashMap(); params.put("languageid", languageId); params.put("carrierciid", carrierCiId); ret = global.puller.webserviceCall("getworddictionary", params, true, null, null); System.out.println(ret); json = ret; gson = new Gson(); reader = new JsonReader(new StringReader(json)); reader.setLenient(true); global.puller.storedData.dictionary = gson.fromJson(reader, WordDictionary.class); global.puller.storedData.dictionary.index = new HashMap(); for (int i = 0; i < global.puller.storedData.dictionary.entries.size(); i++) { global.puller.storedData.dictionary.index.put(global.puller.storedData.dictionary.entries.get(i).systemword, global.puller.storedData.dictionary.entries.get(i).translation); } global.textColor = Color.parseColor(global.puller.storedData.carrierCi.foreGround); } catch (Exception e) { e.printStackTrace(); } } String theUsername = args[1]; String thePassword = args[2]; LinkedHashMap params = new LinkedHashMap(); params.put("server", theServer); params.put("username", theUsername); params.put("password", thePassword); ret = global.puller.webserviceCall("registeruser", params, true, null, null); System.out.println(ret); String json = ret; Gson gson = new Gson(); JsonReader reader = new JsonReader(new StringReader(json)); reader.setLenient(true); global.puller.storedData.loginInfo = gson.fromJson(reader, LoginInfo.class); if (global.puller.storedData.loginInfo.result.equals("ok")) ret = "alldone"; else ret = global.puller.storedData.loginInfo.result; } catch (Exception e) { e.printStackTrace(); ret = "apiError"; } return ret; } protected void onPostExecute(String result) { if (result.equals("alldone")) { global.puller.saveStoredData(); Intent newIntent = new Intent(Login.this, Authentication.class); startActivity(newIntent); } else { if (result.equals("serverNotFound")) errMessage.setText("\n" + global.getTranslation("servernotfound")); if (result.equals("userNotFound")) errMessage.setText("\n" + global.getTranslation("usernotfound")); if (result.equals("passwordNoMatch")) errMessage.setText("\n" + global.getTranslation("passwordnomatch")); if (result.equals("apiError")) errMessage.setText("\n" + global.getTranslation("apierror")); progressDialog.dismiss(); } } } private class LoadingTask extends AsyncTask { protected void onPreExecute() { super.onPreExecute(); } protected String doInBackground(String... params) { return ""; } @Override protected void onPostExecute(String result) { super.onPostExecute(result); } } } package at.inntelco.INNTEL.login; import android.content.Intent; import android.graphics.Color; import android.os.AsyncTask; import android.os.Bundle; import android.util.TypedValue; import android.view.Gravity; import android.view.View; import android.widget.EditText; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ScrollView; import android.widget.TextView; import com.google.gson.Gson; import com.google.gson.JsonObject; import com.google.gson.stream.JsonReader; import at.inntelco.INNTEL.BetterActivity; import at.inntelco.INNTEL.BetterImageView; import at.inntelco.INNTEL.LoadingScreen; import at.inntelco.INNTEL.INNTELApplication; import at.inntelco.INNTEL.R; import at.inntelco.INNTEL.home.Contacts; import java.io.StringReader; import java.util.LinkedHashMap; public class Verification extends BetterActivity { public ScrollView itemBack; TextView errMessage; @Override protected void onCreate(Bundle savedInstanceState) { INNTELApplication application = (INNTELApplication) getApplication(); global = application.global; super.onCreate(savedInstanceState); setStatusBarColorNow(global.puller.storedData.carrierCi.backGround); setContentView(R.layout.activity_login); progressDialog = new LoadingScreen(this, global); progressDialog.show(); buildGUI(); } public void buildGUI() { itemBack = findViewById(R.id.scrollview); itemBack.setBackgroundColor(Color.parseColor(global.puller.storedData.carrierCi.backGround)); LinearLayout theStack = findViewById(R.id.itemstack); theStack.setGravity(Gravity.CENTER); theStack.setClipChildren(false); addVerticalSpacer(theStack, 75, this); BetterImageView headerImage = new BetterImageView(this); LinearLayout.LayoutParams paramsX = new LinearLayout.LayoutParams(global.appleW(180), LinearLayout.LayoutParams.WRAP_CONTENT); headerImage.setLayoutParams(paramsX); headerImage.setScaleType(ImageView.ScaleType.CENTER_INSIDE); headerImage.setAdjustViewBounds(true); String remoteLogo = global.puller.storedData.carrierCi.contenturl +"carrier/"+ global.puller.storedData.carrierCi.id + "/logo.png"; global.puller.loadImage(headerImage, remoteLogo, null, this); theStack.addView(headerImage); addVerticalSpacer(theStack, 45, this); TextView headLine = new TextView(this); headLine.setText(global.getTranslation("twofactorverification")); headLine.setTextSize(TypedValue.COMPLEX_UNIT_PX, global.appleH(22)); headLine.setTextAlignment(View.TEXT_ALIGNMENT_CENTER); headLine.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); headLine.setTextColor(global.textColor); theStack.addView(headLine); errMessage = new TextView(this); errMessage.setText(""); errMessage.setTextSize(TypedValue.COMPLEX_UNIT_PX, global.appleH(22)); errMessage.setTextAlignment(View.TEXT_ALIGNMENT_CENTER); errMessage.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); errMessage.setTextColor(Color.RED); theStack.addView(errMessage); addVerticalSpacer(theStack, 40, this); EditText tokenfield = Login.createInputText(global.getTranslation("pincode"), this); theStack.addView(tokenfield); addVerticalSpacer(theStack, 20, this); View.OnClickListener confirmListener = new View.OnClickListener() { @Override public void onClick(View v) { progressDialog.show(); confirmCode(tokenfield.getText().toString(),global.puller.storedData.loginInfo.dialoguuid); } }; Login.addButton(global.getTranslation("confirm"),confirmListener,theStack,this); addVerticalSpacer(theStack, 20, this); View.OnClickListener againListener = new View.OnClickListener() { @Override public void onClick(View v) { progressDialog.show(); resendCode(); } }; Login.addButton(global.getTranslation("sendpincodeagain"),againListener,theStack,this); } public void confirmCode(String token, String dialoguuid) { if(checkInternet()) new APITask(this).execute(token, dialoguuid); else createErrorDialog("No Internet connection.",()->confirmCode(token,global.puller.storedData.loginInfo.dialoguuid)); } public void resendCode(){ Authentication.sendCode(global.puller.storedData.loginInfo.authMobileNumber,errMessage,this); } private class APITask extends AsyncTask { BetterActivity mother; public APITask(BetterActivity mother) { this.mother = mother; } protected String doInBackground(String... args) { String ret = ""; try { String token = args[0]; String dialoguuid=args[1]; LinkedHashMap params = new LinkedHashMap(); params.put("token", token); params.put("dialoguuid", dialoguuid); ret = global.puller.webserviceCall("checkmobiletoken", params, true, mother.global.puller.storedData.loginInfo.apikey, mother.global.puller.storedData.loginInfo.authorizedApiKey); System.out.println(ret); String json = ret; Gson gson = new Gson(); JsonReader reader = new JsonReader(new StringReader(json)); reader.setLenient(true); JsonObject jobj = gson.fromJson(reader, JsonObject.class); String result = jobj.get("result").getAsString(); if("ok".equals(result)){ ret="alldone"; global.puller.storedData.loginInfo.authorizedApiKey=jobj.get("authorizedApiKey").getAsString(); }else ret = result; } catch (Exception e) { e.printStackTrace(); ret="apiError"; } return ret; } protected void onPostExecute(String result) { if (result.equals("alldone")) { global.puller.storedData.loginInfo.isAuthenticated=true; global.puller.saveStoredData(); Intent newIntent = new Intent(Verification.this, Contacts.class); startActivity(newIntent); } else { if(result.equals("tokenNoMatch")) errMessage.setText("\n"+global.getTranslation("tokennomatch")); else errMessage.setText("\n"+global.getTranslation("apierror")); progressDialog.dismiss(); } } } } package at.inntelco.INNTEL; import android.app.Activity; import android.content.Context; import android.content.DialogInterface; import android.graphics.Color; import android.net.ConnectivityManager; import android.net.NetworkCapabilities; import com.google.android.material.bottomnavigation.BottomNavigationView; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; import android.view.View; import android.view.Window; import android.view.WindowManager; import android.view.inputmethod.InputMethodManager; import android.widget.LinearLayout; public class BetterActivity extends AppCompatActivity { public BottomNavigationView navigation; public Global global = null; public LoadingScreen progressDialog; public int thingsToWaitFor = 0; public int getStatusBarHeight() { int result = 0; int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android"); if (resourceId > 0) { result = getResources().getDimensionPixelSize(resourceId); } return result; } public static void addVerticalSpacer(LinearLayout stack, int height, BetterActivity mother) { View spacer = new View(mother); spacer.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, mother.global.appleH(height))); stack.addView(spacer); } public void setStatusBarColorNow(String theColor){ Window window = this.getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.setStatusBarColor(Color.parseColor(theColor)); } public static void addHorizontalSpacer(LinearLayout stack, int width, BetterActivity mother) { View spacer = new View(mother); spacer.setLayoutParams(new LinearLayout.LayoutParams(mother.global.appleW(width), LinearLayout.LayoutParams.MATCH_PARENT)); stack.addView(spacer); } public void createInfoDialog(String headline, String msg) { AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this); alertBuilder.setMessage(msg); alertBuilder.setTitle(headline); alertBuilder.setPositiveButton( "Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { } }); AlertDialog alertDialog = alertBuilder.create(); alertDialog.setCancelable(false); alertDialog.setCanceledOnTouchOutside(false); alertDialog.show(); } public void createErrorDialog(String msg, Runnable callback) { AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this); alertBuilder.setMessage(msg); alertBuilder.setPositiveButton( "Retry", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { if (checkInternet()) { dialog.cancel(); callback.run(); //callback.accept(0); } else createErrorDialog(msg, callback); } }); AlertDialog alertDialog = alertBuilder.create(); alertDialog.setCancelable(false); alertDialog.setCanceledOnTouchOutside(false); alertDialog.show(); } public void hideKeyboard() { System.out.println("hideKeyboard called"); InputMethodManager imm = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE); View view = getCurrentFocus(); if (view == null) { view = new View(this); } view.clearFocus(); imm.hideSoftInputFromWindow(view.getWindowToken(), 0); } public boolean checkInternet() { return checkInternet(this); } public static boolean checkInternet(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); if (cm != null) { NetworkCapabilities capabilities = cm.getNetworkCapabilities(cm.getActiveNetwork()); return capabilities != null && (capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) || capabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR)); } return false; } public void waitForThisBeforeHidingLoadingScreen() { thingsToWaitFor++; } public void hideLoadingScreenIfNothingLeftToWaitFor() { if (thingsToWaitFor < 1) { if (progressDialog != null) { if (progressDialog.isShowing()) { progressDialog.dismiss(); } } } } public void decreaseThingsToWaitForAndHideLoadingScreen() { thingsToWaitFor--; if (thingsToWaitFor < 1) { thingsToWaitFor = 0; if (progressDialog != null) { if (progressDialog.isShowing()) { progressDialog.dismiss(); } } } } } package at.inntelco.INNTEL; import android.view.View; public class BetterClickListener implements View.OnClickListener { @Override public void onClick(View view) { } } package at.inntelco.INNTEL; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Path; import android.graphics.Rect; import android.graphics.RectF; import android.renderscript.Allocation; import android.renderscript.Element; import android.renderscript.Matrix4f; import android.renderscript.RenderScript; import android.renderscript.ScriptIntrinsicBlur; import android.renderscript.ScriptIntrinsicColorMatrix; import androidx.appcompat.widget.AppCompatImageView; import android.util.AttributeSet; import android.util.TypedValue; public class BetterImageView extends AppCompatImageView { public Context context = null; public RenderScript rs; public ScriptIntrinsicBlur blurScript; public ScriptIntrinsicColorMatrix colorMatrixScript; public Bitmap shadowBitmap = null; public int roundedCornerPx = 0; private float customElevation = 0f; private boolean clipShadow = true; private boolean isTranslucent = true; private Path roundedPath; public BetterImageView(Context context) { super(context); this.context = context; } public BetterImageView(Context context, AttributeSet attrs) { super(context, attrs); this.context = context; } public BetterImageView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); this.context = context; } public BetterImageView(Context context, AttributeSet attrs, int defStyleAttr, boolean clipShadow, boolean isTranslucent) { super(context, attrs, defStyleAttr); this.context = context; this.clipShadow = clipShadow; this.isTranslucent = isTranslucent; } public void setIsTranslucent(boolean isTranslucent) { this.isTranslucent = isTranslucent; invalidate(); } public void setClipShadow(boolean clipShadow) { this.clipShadow = clipShadow; invalidate(); } @Override public void setElevation(float elevation) { customElevation = elevation; invalidate(); } @Override protected void onDetachedFromWindow() { if (!this.isInEditMode()) { blurScript.destroy(); colorMatrixScript.destroy(); rs.destroy(); } super.onDetachedFromWindow(); } @Override protected void onAttachedToWindow() { if (!this.isInEditMode()) { rs = RenderScript.create(context); Element element = Element.U8_4(rs); blurScript = ScriptIntrinsicBlur.create(rs, element); colorMatrixScript = ScriptIntrinsicColorMatrix.create(rs, element); } super.onAttachedToWindow(); } @Override public void invalidate() { shadowBitmap = null; super.invalidate(); } @Override protected void onDraw(Canvas canvas) { canvas.save(); if (shadowBitmap == null && canvas != null && customElevation > 0) { generateShadow(); } if (shadowBitmap != null) { if (!clipShadow) { Rect newRect = canvas.getClipBounds(); newRect.inset(-2 * (int) getBlurRadius(), -2 * (int) getBlurRadius()); canvas.clipRect(newRect); } if (getDrawable() != null) { Rect bounds = getDrawable().copyBounds(); canvas.drawBitmap(shadowBitmap, (float) bounds.left - getBlurRadius(), bounds.top - getBlurRadius() / 2f, null); } } int width = getWidth(); int height = getHeight(); if (roundedCornerPx > 0 && roundedPath == null && (width > 0 && height > 0)) { roundedPath = new Path(); roundedPath.addRoundRect(new RectF(0, 0, width, height), roundedCornerPx, roundedCornerPx, Path.Direction.CW); } if (roundedPath != null) canvas.clipPath(roundedPath); canvas.save(); canvas.restore(); super.onDraw(canvas); } private float getBlurRadius() { float maxElevation = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 24f, this.getResources().getDisplayMetrics()); return Math.min(25f * (customElevation / maxElevation), 25f); } private void generateShadow() { if (getDrawable() != null) { float blurRadius = getBlurRadius(); int width = getWidth() + 2 * (int) blurRadius; int height = getHeight() + 2 * (int) blurRadius; Bitmap bitmap = null; if (width <= 0 || height <= 0) { bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888); } else { bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); } Canvas canvas = new Canvas(bitmap); canvas.translate(getPaddingLeft() + blurRadius, getPaddingTop() + blurRadius); if (getImageMatrix() != null) { canvas.concat(getImageMatrix()); } getDrawable().draw(canvas); Allocation allocationIn = Allocation.createFromBitmap(rs, bitmap); Allocation allocationOut = Allocation.createTyped(rs, allocationIn.getType()); float[] floatArrayTrans = {0.4f, 0f, 0f, 0f, 0f, 0.4f, 0f, 0f, 0f, 0f, 0.4f, 0f, 0f, 0f, 0f, 0.6f}; float[] floatArrayOpaqe = {0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f, 0.4f}; Matrix4f matrix = null; if (isTranslucent) { matrix = new Matrix4f(floatArrayTrans); } else { matrix = new Matrix4f(floatArrayOpaqe); } colorMatrixScript.setColorMatrix(matrix); colorMatrixScript.forEach(allocationIn, allocationOut); blurScript.setRadius(getBlurRadius()); blurScript.setInput(allocationOut); blurScript.forEach(allocationIn); allocationIn.copyTo(bitmap); allocationIn.destroy(); allocationOut.destroy(); shadowBitmap = bitmap; } } } package at.inntelco.INNTEL; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.util.Log; import androidx.core.content.ContextCompat; import static at.inntelco.INNTEL.INNTELApplication.corePreferences; public class BootReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if (Intent.ACTION_SHUTDOWN.equals(intent.getAction())) { android.util.Log.d( "INNTEL", "[Boot Receiver] Device is shutting down" ); } else if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) { boolean autoStart = corePreferences.isAutoStart(); System.out.println("[Boot Receiver] Device is starting, autoStart is " + autoStart); if (autoStart) { } } } } package at.inntelco.INNTEL; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.util.AttributeSet; import android.view.View; public class CircleView extends View { private static final int DEFAULT_CIRCLE_COLOR = Color.RED; private int circleColor = DEFAULT_CIRCLE_COLOR; private Paint paint; public CircleView(Context context) { super(context); init(context, null); } public CircleView(Context context, AttributeSet attrs) { super(context, attrs); init(context, attrs); } private void init(Context context, AttributeSet attrs) { paint = new Paint(); paint.setAntiAlias(true); } public void setCircleColor(int circleColor) { this.circleColor = circleColor; invalidate(); } public int getCircleColor() { return circleColor; } protected void onDraw(Canvas canvas) { super.onDraw(canvas); int w = getWidth(); int h = getHeight(); int pl = getPaddingLeft(); int pr = getPaddingRight(); int pt = getPaddingTop(); int pb = getPaddingBottom(); int usableWidth = w - (pl + pr); int usableHeight = h - (pt + pb); int radius = Math.min(usableWidth, usableHeight) / 2; int cx = pl + (usableWidth / 2); int cy = pt + (usableHeight / 2); paint.setColor(circleColor); canvas.drawCircle(cx, cy, radius, paint); } } package at.inntelco.INNTEL; import android.Manifest; import android.annotation.SuppressLint; import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.graphics.PixelFormat; import android.media.AudioManager; import android.os.Handler; import android.os.Looper; import android.os.PowerManager; import android.os.Vibrator; import android.telephony.PhoneStateListener; import android.telephony.TelephonyManager; import android.util.TypedValue; import android.view.Gravity; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.WindowManager; import androidx.core.app.NotificationCompat; import org.linphone.core.*; import org.linphone.mediastream.Log; import org.linphone.mediastream.Version; import java.io.File; import java.util.Date; import java.util.Timer; import java.util.TimerTask; import at.inntelco.INNTEL.data.CallEntity; import at.inntelco.INNTEL.data.User; import at.inntelco.INNTEL.home.CallingScreenLocked; import static android.content.Context.NOTIFICATION_SERVICE; import static android.content.Context.POWER_SERVICE; import static at.inntelco.INNTEL.INNTELApplication.corePreferences; public class CoreContext { public boolean callRunning=false; private Context context; public Core core; public boolean stopped; public CoreContext(Context context, Config coreConfig, boolean useAutoStartDescription) { this.context = context; this.stopped = false; this.core = Factory.instance().createCoreWithConfig(coreConfig, context); this.stopped = false; Log.i("[Context] Ready"); } public boolean loggedIn = false; private CoreListenerStub listener = new CoreListenerStub() { @Override public void onAccountRegistrationStateChanged(Core core, Account account, RegistrationState state, String message) { if (state == RegistrationState.Ok) { loggedIn = true; } else { loggedIn = false; } } @Override public void onGlobalStateChanged(Core core, GlobalState state, String message) { Log.i("[Context] Global state changed [" + state + "]"); if (state == GlobalState.On) { Log.d("[Context] Configuration is \n : " + core.getConfig().dump()); } } @Override public void onCallStateChanged(Core core, Call call, Call.State state, String message) { System.out.println("onCallStateChanged "+state.name()); INNTELApplication application = (INNTELApplication) context.getApplicationContext(); if(application.global==null){ System.out.println("new global created"); application.global=new Global(context); MainActivity.initGlobal(context,application.global); } // This function will be called each time a call state changes, // which includes new incoming/outgoing calls switch (state) { case OutgoingInit: // First state an outgoing call will go through System.out.println("Corehandler Listener Outgoing"); break; case OutgoingProgress: // Right after outgoing init break; case OutgoingRinging: // This state will be reached upon reception of the 180 RINGING break; case Connected: // When the 200 OK has been received break; case StreamsRunning: // This state indicates the call is active. // You may reach this state multiple times, for example after a pause/resume // or after the ICE negotiation completes // Wait for the call to be connected before allowing a call update break; case Paused: // When you put a call in pause, it will became Paused break; case PausedByRemote: // When the remote end of the call pauses it, it will be PausedByRemote break; case Updating: // When we request a call update, for example when toggling video case UpdatedByRemote: // When the remote requests a call update break; case IncomingReceived: System.out.println("XXX1"); String remAdr = call.getRemoteAddress().asStringUriOnly(); System.out.println("XXX11"); String secondPart = remAdr.split("sip:")[1]; System.out.println("XXX12"); String numberCrude = secondPart.split("@")[0]; System.out.println("XXX13"); String normNum = Utilities.normalizeNumber(numberCrude, application.global.puller.storedData.vorWahl); System.out.println("XXX14"); User user = application.global.puller.storedData.user.findInContactByNormalizedNumber(normNum); System.out.println("XXX15"); if (user == null) { user = new User(); user.mobile = normNum; user.lastname = "unknown"; } System.out.println("XXX2"); application.global.puller.storedData.callEntity = new CallEntity(application.global.puller.storedData.callList.size() + "", user, false, new Date()); System.out.println("XXX3"); application.global.puller.storedData.callList.add(application.global.puller.storedData.callEntity); System.out.println("XXX4"); application.global.puller.saveStoredData(); System.out.println("XXX5"); showHeadsUpNotification(application.global.globalContext, user.mobile, user.lastname); System.out.println("XXX6"); break; case Released: NotificationManager notificationManager = (NotificationManager) application.global.globalContext.getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.cancel(0); callRunning = false; break; default: break; } } }; public static void showHeadsUpNotification(Context context, String title, String text) { PowerManager powerManager = (PowerManager) context.getSystemService(POWER_SERVICE); NotificationManager notificationManager = (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE); @SuppressLint("InvalidWakeLockTag") PowerManager.WakeLock wakeLock = powerManager.newWakeLock( PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "incomingCallWakeLock"); wakeLock.acquire(); CharSequence name = "Call information"; String description = "Call incoming"; int importance = NotificationManager.IMPORTANCE_HIGH; NotificationChannel channel = new NotificationChannel(CHANNEL_ID, name, importance); channel.setDescription(description); channel.setVibrationPattern(new long[]{0, 1000}); channel.enableVibration(true); channel.setLockscreenVisibility(NotificationCompat.VISIBILITY_PUBLIC); notificationManager.createNotificationChannel(channel); Intent acceptIntent = new Intent(context, NotificationReceiver.class); acceptIntent.setAction("Accept"); PendingIntent acceptPendingIntent = PendingIntent.getBroadcast(context, 0, acceptIntent, PendingIntent.FLAG_UPDATE_CURRENT); Intent declineIntent = new Intent(context, NotificationReceiver.class); declineIntent.setAction("Decline"); PendingIntent declinePendingIntent = PendingIntent.getBroadcast(context, 1, declineIntent, PendingIntent.FLAG_UPDATE_CURRENT); Intent fullScreenIntent = new Intent(context, CallingScreenLocked.class); @SuppressLint("UnspecifiedImmutableFlag") PendingIntent fullScreenPendingIntent = PendingIntent.getActivity(context, 0, fullScreenIntent, 0); @SuppressLint("NotificationTrampoline") NotificationCompat.Builder builder = new NotificationCompat.Builder(context, CHANNEL_ID) .setSmallIcon(R.mipmap.ic_launcher) .setContentTitle(title) .setContentText(text) .setPriority(NotificationCompat.PRIORITY_HIGH) .addAction(R.mipmap.ic_launcher, "Accept", acceptPendingIntent) .addAction(R.mipmap.ic_launcher, "Decline", declinePendingIntent) .setFullScreenIntent(fullScreenPendingIntent, true) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .setCategory(NotificationCompat.CATEGORY_ALARM) .setAutoCancel(true); Notification theNotification = builder.build(); notificationManager.notify(0, theNotification); } private static final String CHANNEL_ID = "my_channel_id"; private void removeCallOverlay() { System.out.println("removeCallOverlay."); } private void onCallStarted(Call call) { System.out.println("onCallStarted."); } private void onOutgoingStarted(Call call) { System.out.println("onOutgoingStarted."); } private void answerCall(Call call) { System.out.println("answerCall."); call.accept(); } private void onIncomingReceived(Call call) { System.out.println("onIncomingReceived received."); } public void start(){ start(false); } public void start(boolean isPush) { Log.i("[Context] Starting"); core.addListener(listener); if (isPush) { Log.i("[Context] Push received, assume in background"); core.enterBackground(); } core.getConfig().setBool("net", "use_legacy_push_notification_params", true); core.start(); configureCore(); //initPhoneStateListener(); if (corePreferences.isKeepServiceAlive()) { Log.i("[Context] Background mode setting is enabled, starting Service"); } } /* public void initPhoneStateListener() { Log.i("[Context] Registering notification_phone state listener"); if (Utilities.hasPermission(context,"READ_PHONE_STATE")) { try { TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); telephonyManager.listen(phoneStateListener, PhoneStateListener.LISTEN_CALL_STATE); } catch (SecurityException exception) { boolean hasReadPhoneStatePermission = Utilities.hasPermission(context, Manifest.permission.READ_PHONE_NUMBERS); Log.e("[Context] Failed to create phone state listener: " + exception + ", READ_PHONE_STATE permission status is " + hasReadPhoneStatePermission); } } else { Log.w("[Context] Can't create phone state listener, READ_PHONE_STATE permission isn't granted"); } } */ public void stop() { Log.i("[Context] Stopping"); TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); Log.i("[Context] Unregistering phone state listener"); // telephonyManager.listen(phoneStateListener, PhoneStateListener.LISTEN_NONE); core.stop(); core.removeListener(listener); stopped = true; } private void configureCore() { Log.i("[Context] Configuring Core"); core.setZrtpSecretsFile(context.getFilesDir().getAbsolutePath() + "/zrtp_secrets"); initUserCertificates(); computeUserAgent(); Log.i("[Context] Core configured"); } private void computeUserAgent() { String deviceName = "theDevice"; String appName = "INNTEL"; String androidVersion = BuildConfig.VERSION_NAME; String userAgent = appName + "/" + androidVersion + " (" + deviceName + ") LinphoneSDK"; String sdkVersion = context.getString(R.string.linphone_sdk_version); String sdkBranch = context.getString(R.string.linphone_sdk_branch); String sdkUserAgent = sdkVersion + " (" + sdkBranch + ")"; core.setUserAgent(userAgent, sdkUserAgent); } private void initUserCertificates() { String userCertsPath = context.getFilesDir().getAbsolutePath() + "/user-certs"; File f = new File(userCertsPath); if (!f.exists()) { if (!f.mkdir()) { Log.e("[Context] " + userCertsPath + " can't be created."); } } core.setUserCertificatesPath(userCertsPath); } } package at.inntelco.INNTEL; import android.content.Context; import org.linphone.core.Config; import org.linphone.mediastream.Log; import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; import java.math.BigInteger; import java.security.MessageDigest; import static at.inntelco.INNTEL.INNTELApplication.coreContext; public class CorePreferences { private Context context; private Config _config = null; public CorePreferences(Context context) { this.context = context; } public Config getConfig() { return _config != null ? _config : coreContext.core.getConfig(); } public void setConfig(Config value) { _config = value; } public boolean isAutomaticallyCreatePushGatewayAccount() { return getConfig().getBool("app", "auto_create_push_gateway_account", true); } public boolean isShowLatestSnapshot() { return getConfig().getBool("devices", "latest_snapshot", true); } public void setShowLatestSnapshot(boolean value) { getConfig().setBool("devices", "latest_snapshot", value); } public String getDefaultActionsMethodType() { return getConfig().getString("default_actions", "method_type", null); } public boolean isDebugLogs() { return getConfig().getBool("app", "debug", true); } public void setDebugLogs(boolean value) { getConfig().setBool("app", "debug", value); } public boolean isAutoStart() { return getConfig().getBool("app", "auto_start", true); } public void setAutoStart(boolean value) { getConfig().setBool("app", "auto_start", value); } public boolean isKeepServiceAlive() { return getConfig().getBool("app", "keep_service_alive", false); } public void setKeepServiceAlive(boolean value) { getConfig().setBool("app", "keep_service_alive", value); } public String[] getAvailableAudioCodecs() { return new String[]{"pcmu", "pcma", "opus", "g729"}; } public String[] getEnabledVideoCodecsByDefault() { return new String[]{"h264"}; } public String[] getEnabledAudioCodecsByDefault() { return new String[]{"pcmu", "pcma", "opus"}; } public void setDeviceName(String value) { getConfig().setString("app", "device_name", value); } public boolean isVibrateWhileIncomingCall() { return getConfig().getBool("app", "incoming_call_vibration", true); } public void setVibrateWhileIncomingCall(boolean value) { getConfig().setBool("app", "incoming_call_vibration", value); } public boolean isAutoAnswerEnabled() { return getConfig().getBool("app", "auto_answer", false); } public void setAutoAnswerEnabled(boolean value) { getConfig().setBool("app", "auto_answer", value); } public int getAutoAnswerDelay() { return getConfig().getInt("app", "auto_answer_delay", 0); } public void setAutoAnswerDelay(int value) { getConfig().setInt("app", "auto_answer_delay", value); } public boolean isShowCallOverlay() { return getConfig().getBool("app", "call_overlay", false); } public void setShowCallOverlay(boolean value) { getConfig().setBool("app", "call_overlay", value); } public String getXmlRpcServerUrl() { return getConfig().getString("assistant", "xmlrpc_url", null); } public void setXmlRpcServerUrl(String value) { getConfig().setString("assistant", "xmlrpc_url", value); } public String getPasswordAlgo() { return getConfig().getString("assistant", "password_algo", null); } public void setPasswordAlgo(String value) { getConfig().setString("assistant", "password_algo", value); } public String getLoginDomain() { return getConfig().getString("assistant", "domain", null); } public void setLoginDomain(String value) { getConfig().setString("assistant", "domain", value); } public String getConfigPath() { return context.getFilesDir().getAbsolutePath() + "/.inntelconfig"; } public String getFactoryConfigPath() { return context.getFilesDir().getAbsolutePath() + "/inntelconfig"; } } package at.inntelco.INNTEL; import android.content.Context; import android.graphics.Color; import android.graphics.PorterDuff; import android.util.TypedValue; import android.view.Gravity; import android.view.View; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; public class Expander extends LinearLayout { public BetterImageView infoBut; private boolean open = false; public void toggleOpenClose(){ if(open){ open=false; infoBut.setImageResource(R.drawable.arrowup); }else{ open=true; infoBut.setImageResource(R.drawable.arrowdown); } } public Expander(Context context){ super(context); } public Expander(Context context, BetterActivity mother, String caption) { super(context); setOrientation(LinearLayout.HORIZONTAL); setVerticalGravity(Gravity.CENTER); setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, mother.global.appleH(55))); BetterActivity.addHorizontalSpacer(this, 12, mother); TextView aLabel = new TextView(context); aLabel.setText(caption); aLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX, mother.global.appleH(20)); aLabel.setTextAlignment(View.TEXT_ALIGNMENT_TEXT_START); aLabel.setLayoutParams(new LinearLayout.LayoutParams(mother.global.appleW(332), LinearLayout.LayoutParams.WRAP_CONTENT)); aLabel.setTextColor(mother.global.textColor); addView(aLabel); infoBut = new BetterImageView(context); LinearLayout.LayoutParams infoButParams = new LinearLayout.LayoutParams(mother.global.appleW(20), LinearLayout.LayoutParams.WRAP_CONTENT); infoBut.setLayoutParams(infoButParams); infoBut.setScaleType(ImageView.ScaleType.CENTER_INSIDE); infoBut.setAdjustViewBounds(true); infoBut.setImageResource(R.drawable.arrowup); infoBut.setBackgroundColor(Color.parseColor(mother.global.puller.storedData.carrierCi.backGround)); infoBut.setColorFilter(Color.parseColor(mother.global.puller.storedData.carrierCi.foreGround), PorterDuff.Mode.SRC_IN); addView(infoBut); } } package at.inntelco.INNTEL; import android.content.Context; import android.graphics.Color; import android.view.MenuItem; import org.linphone.core.Core; import java.io.File; public class Global { public Context globalContext; public Puller puller; public String saveFileNameOnly = "offlineUserInfo.mi"; public String saveFileName = ""; public String saveDirName = "INNTELsave"; public String saveDirNameAbsolute; public File saveDirectory; public int heightPixels; public int widthPixels; public int textColor = Color.parseColor(Utilities.fromRGBA(0, 66, 99, 255)); //#006699 public int colorTop = Color.parseColor(Utilities.fromRGBA(0, 66, 99, 255)); public int colorBottom = Color.parseColor(Utilities.fromRGBA(0, 66, 99, 255)); public MenuItem activeMenuItem; public Global(Context context) { globalContext = context; puller = new Puller(this); } public String getTranslation(String systemWord) { String ret = systemWord; String lookup = null; try { lookup = puller.storedData.dictionary.index.get(systemWord); } catch (Exception e) { } if (null != lookup) ret = lookup; return ret; } public int appleW(int width) { int ret = -1; ret = width * widthPixels / 375; return ret; } public int appleH(int height) { int ret = -1; ret = height * heightPixels / 667; return ret; } } package at.inntelco.INNTEL; import android.app.Application; import android.content.Context; import android.content.res.Configuration; import org.linphone.core.Core; import org.linphone.core.CoreListenerStub; import org.linphone.core.Factory; import org.linphone.core.FriendList; import org.linphone.core.GlobalState; import org.linphone.core.LogCollectionState; import org.linphone.mediastream.Log; public class INNTELApplication extends Application { public Global global; public static INNTELApplication instance; public static CorePreferences corePreferences; public static CoreContext coreContext; /* private CoreListenerStub coreListener = new CoreListenerStub() { @Override public void onGlobalStateChanged(Core core, GlobalState state, String message) { } @Override public void onFriendListCreated(Core core, FriendList friendList) { if (core.getGlobalState() == GlobalState.On) { Log.i("[DeviceStore] friend list created. " + friendList.getDisplayName()); } } }; */ public boolean ensureCoreExists(Context context){ return ensureCoreExists(context,false,false); } public boolean ensureCoreExists( Context context, boolean useAutoStartDescription, boolean force) { if (!force && coreContext != null && !coreContext.stopped) { return false; } Factory.instance().setLogCollectionPath(context.getFilesDir().getAbsolutePath()); Factory.instance().enableLogCollection(LogCollectionState.Enabled); corePreferences = new CorePreferences(context); org.linphone.core.Config config = Factory.instance().createConfigWithFactory( corePreferences.getConfigPath(), corePreferences.getFactoryConfigPath() ); config.setString("storage", "call_logs_db_uri", context.getFilesDir().getAbsolutePath() + "/linphone-log-history.db"); corePreferences.setConfig(config); Factory.instance().setDebugMode(corePreferences.isDebugLogs(), "INNTEL"); Log.i("[Application] Core context created"); coreContext = new CoreContext(context, config, useAutoStartDescription); //coreContext.core.addListener(coreListener); coreContext.start(); if (corePreferences.getConfig().getBool("app", "first_launch", true)) { corePreferences.getConfig().setBool("app", "first_launch", false); } coreContext.core.setNativeRingingEnabled(true); coreContext.core.setFriendListSubscriptionEnabled(true); //coreContext.core.setFriendsDatabasePath(context.getFilesDir().getAbsolutePath() + "/devices.db"); setDefaultCodecs(); return true; } public static boolean contextExists() { return coreContext != null; } public static void setDefaultCodecs() { } @Override public void onCreate() { super.onCreate(); instance = this; ensureCoreExists(getApplicationContext(), false, false); } public boolean landcape() { int orientation = getResources().getConfiguration().orientation; return orientation == Configuration.ORIENTATION_LANDSCAPE; } } package at.inntelco.INNTEL; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.util.Log; import com.google.firebase.messaging.FirebaseMessagingService; import com.google.firebase.messaging.RemoteMessage; import java.util.Iterator; import java.util.List; import java.util.Map; import org.json.JSONObject; import org.linphone.core.Core; import org.linphone.core.tools.compatibility.DeviceUtils; import org.linphone.core.tools.service.AndroidDispatcher; import org.linphone.core.tools.service.CoreManager; public class INNTELFirebaseMessaging extends FirebaseMessagingService { public INNTELFirebaseMessaging() { } public void onNewToken(String token) { Log.i("FirebaseIdService", "[Push Notification] Refreshed token: " + token); if (CoreManager.isReady()) { CoreManager.instance().setPushToken(token); } } public void onMessageReceived(final RemoteMessage remoteMessage) { Log.i("FirebaseMessaging", "[Push Notification] Received"); Runnable pushRunnable = new Runnable() { public void run() { INNTELFirebaseMessaging.this.onPushReceived(remoteMessage); } }; AndroidDispatcher.dispatchOnUIThread(pushRunnable); } private void onPushReceived(RemoteMessage remoteMessage) { System.out.println("YYYY push 1"); if (!CoreManager.isReady()) { this.storePushRemoteMessage(remoteMessage); this.notifyAppPushReceivedWithoutCoreAvailable(); } else { org.linphone.core.tools.Log.i(new Object[]{"[Push Notification] Received: " + this.remoteMessageToString(remoteMessage)}); if (CoreManager.instance() != null) { Core core = CoreManager.instance().getCore(); if (core != null) { Map data = remoteMessage.getData(); String callId = DeviceUtils.getStringOrDefaultFromMap(data, "call-id", ""); String payload = (new JSONObject(data)).toString(); org.linphone.core.tools.Log.i(new Object[]{"[Push Notification] Notifying Core we have received a push for Call-ID [" + callId + "]"}); CoreManager.instance().processPushNotification(callId, payload, false); } else { org.linphone.core.tools.Log.w(new Object[]{"[Push Notification] No Core found, notifying application directly"}); this.storePushRemoteMessage(remoteMessage); this.notifyAppPushReceivedWithoutCoreAvailable(); } } } } private void storePushRemoteMessage(RemoteMessage remoteMessage) { Context context = this.getApplicationContext(); SharedPreferences sharedPref = context.getSharedPreferences("push_notification_storage", 0); Map allEntries = sharedPref.getAll(); for (Map.Entry entry : allEntries.entrySet()) { System.out.println(entry.getKey() + ": " + entry.getValue()); } SharedPreferences.Editor editor = sharedPref.edit(); Map data = remoteMessage.getData(); String callId = DeviceUtils.getStringOrDefaultFromMap(data, "call-id", ""); editor.putString("call-id", callId); String payload = (new JSONObject(data)).toString(); editor.putString("payload", payload); editor.apply(); Log.i("FirebaseMessaging", "[Push Notification] Push information stored for Call-ID [" + callId + "]"); sharedPref = context.getSharedPreferences("push_notification_storage", 0); allEntries = sharedPref.getAll(); for (Map.Entry entry : allEntries.entrySet()) { System.out.println(entry.getKey() + ": " + entry.getValue()); } } private void notifyAppPushReceivedWithoutCoreAvailable() { Intent intent = new Intent(); intent.setAction("org.linphone.core.action.PUSH_RECEIVED"); PackageManager pm = this.getPackageManager(); List matches = pm.queryBroadcastReceivers(intent, 0); Iterator var4 = matches.iterator(); while(var4.hasNext()) { ResolveInfo resolveInfo = (ResolveInfo)var4.next(); String packageName = resolveInfo.activityInfo.applicationInfo.packageName; if (packageName.equals(this.getPackageName())) { Intent explicit = new Intent(intent); ComponentName cn = new ComponentName(packageName, resolveInfo.activityInfo.name); explicit.setComponent(cn); this.sendBroadcast(explicit); break; } } } private String remoteMessageToString(RemoteMessage remoteMessage) { StringBuilder builder = new StringBuilder(); builder.append("From ["); builder.append(remoteMessage.getFrom()); builder.append("], Message Id ["); builder.append(remoteMessage.getMessageId()); builder.append("], TTL ["); builder.append(remoteMessage.getTtl()); builder.append("], Original Priority ["); builder.append(remoteMessage.getOriginalPriority()); builder.append("], Received Priority ["); builder.append(remoteMessage.getPriority()); builder.append("], Sent Time ["); builder.append(remoteMessage.getSentTime()); builder.append("], Data ["); builder.append((new JSONObject(remoteMessage.getData())).toString()); builder.append("]"); return builder.toString(); } } package at.inntelco.INNTEL; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; public class INNTELPushBroadcastReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { System.out.println("YYYYYYYYYYYYYYY Push Received !"); INNTELApplication.instance.ensureCoreExists(context); } } package at.inntelco.INNTEL; import android.app.Dialog; import android.content.Context; import android.graphics.Color; import android.graphics.drawable.GradientDrawable; import android.view.WindowManager; import android.widget.RelativeLayout; public class LoadingScreen extends Dialog { public LoadingScreen(Context context, Global global) { super(context, R.style.null_style); setContentView(R.layout.custom_progress); getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT); RelativeLayout loadingBack= (RelativeLayout) findViewById(R.id.loadingback); GradientDrawable gd = new GradientDrawable( GradientDrawable.Orientation.BOTTOM_TOP, new int[]{global.colorBottom, global.colorTop}); loadingBack.setBackground(gd); } } package at.inntelco.INNTEL; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.graphics.Color; import android.os.AsyncTask; import android.os.Bundle; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; import android.util.DisplayMetrics; import com.google.gson.Gson; import com.google.gson.stream.JsonReader; import at.inntelco.INNTEL.data.CarrierCi; import at.inntelco.INNTEL.data.WordDictionary; import at.inntelco.INNTEL.home.Contacts; import at.inntelco.INNTEL.login.Login; import java.io.File; import java.io.StringReader; import java.util.HashMap; import java.util.LinkedHashMap; public class MainActivity extends AppCompatActivity { public Global global; public LoadingScreen progressDialog; public void startApiTask(String carrierCiId){ new APITask(this).execute(carrierCiId); } public void goon(String carrierCiId){ if (checkInternet()) startApiTask(carrierCiId); else { createErrorDialog("No Internet Connection.", () -> startApiTask(carrierCiId) ); } } public void askForLiveOrTest(String msg, Runnable callback){ AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this); alertBuilder.setMessage(msg); //alertBuilder.setCancelable(false); alertBuilder.setPositiveButton( "TEST", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { global.puller.storedData.testSystemChosen = true; dialog.cancel(); callback.run(); } }); alertBuilder.setNegativeButton( "LIFE", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { global.puller.storedData.testSystemChosen = false; dialog.cancel(); callback.run(); } }); AlertDialog alertDialog = alertBuilder.create(); alertDialog.setCancelable(false); alertDialog.setCanceledOnTouchOutside(false); alertDialog.show(); } public boolean checkInternet(){ return BetterActivity.checkInternet(this); } /* Use Supplier if it takes nothing, but returns something. Use Consumer if it takes something, but returns nothing. Use Callable if it returns a result and might throw Exceptions. Use Runnable if it does neither and cannot throw. */ public void createErrorDialog(String msg, Runnable callback){ AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this); alertBuilder.setMessage(msg); //alertBuilder.setCancelable(false); alertBuilder.setPositiveButton( "Retry", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { if (checkInternet()) { dialog.cancel(); callback.run(); }else createErrorDialog(msg, callback); } }); /* alertBuilder.setNegativeButton( "No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); */ AlertDialog alertDialog = alertBuilder.create(); alertDialog.setCancelable(false); alertDialog.setCanceledOnTouchOutside(false); alertDialog.show(); } public static void initGlobal(Context theContext, Global theGlobal){ DisplayMetrics displayMetrics = theContext.getResources().getDisplayMetrics(); theGlobal.heightPixels = displayMetrics.heightPixels; theGlobal.widthPixels = displayMetrics.widthPixels; File appFilesDir = theContext.getFilesDir(); String filename = appFilesDir.getAbsolutePath() + "/" + theGlobal.saveDirName; theGlobal.saveDirectory = new File(filename); theGlobal.saveDirectory.mkdirs(); theGlobal.saveDirNameAbsolute = theGlobal.saveDirectory.getAbsolutePath(); theGlobal.saveFileName = theGlobal.saveDirNameAbsolute + "/" + theGlobal.saveFileNameOnly; theGlobal.puller.loadStoredData(); } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); INNTELApplication application = (INNTELApplication) getApplication(); if (application.global == null) { System.out.println("new global created"); application.global = new Global(this); initGlobal(this,application.global); } global = application.global; setContentView(R.layout.activity_main); if (global.puller.storedData == null) { System.out.println("nothing yet"); global.puller.storedData = new StoredData(); //todo: replace with deep link id //set true for publishing so that dialog test-or-live? will not appear. boolean publish = true; if(publish) { global.puller.storedData.testSystemChosen = false; goon("2"); }else askForLiveOrTest("Test-, or Live System ?", () -> goon("2")); } else { if(global.puller.storedData.loginInfo !=null && global.puller.storedData.loginInfo.isAuthenticated) { global.textColor = Color.parseColor(global.puller.storedData.carrierCi.foreGround); Intent newIntent = new Intent(MainActivity.this, Contacts.class); Intent intent = getIntent(); Bundle extras = intent.getExtras(); if(extras!=null) { String theCallId = extras.getString("theCallId"); if (theCallId != null) { System.out.println("theCallId in intent found."); newIntent.putExtra("theCallId", theCallId); } } startActivity(newIntent); }else { Intent newIntent = new Intent(MainActivity.this, Login.class); startActivity(newIntent); } } } public void goOen() { Intent newIntent = new Intent(MainActivity.this, Login.class); startActivity(newIntent); } private class APITask extends AsyncTask { String usedCarrierCiID = ""; AppCompatActivity mother; public APITask(AppCompatActivity mother) { this.mother = mother; } protected String doInBackground(String... args) { if(global.puller.storedData.testSystemChosen) global.puller.storedData.apiServerUrl = "XXX"; String ret = ""; try { usedCarrierCiID = args[0]; if(global.puller.storedData.testSystemChosen) usedCarrierCiID = "1"; LinkedHashMap params = new LinkedHashMap(); params.put("carrierciid", usedCarrierCiID); ret = global.puller.webserviceCall("getcarrierci", params, true,null,null); System.out.println(ret); String json = ret; Gson gson = new Gson(); JsonReader reader = new JsonReader(new StringReader(json)); reader.setLenient(true); global.puller.storedData.carrierCi = gson.fromJson(reader, CarrierCi.class); global.puller.storedData.carrierCi.id = usedCarrierCiID; String languageId = global.puller.storedData.carrierCi.languageId; params = new LinkedHashMap(); params.put("languageid", languageId); params.put("carrierciid", usedCarrierCiID); ret = global.puller.webserviceCall("getworddictionary", params, true,null,null); System.out.println(ret); json = ret; gson = new Gson(); reader = new JsonReader(new StringReader(json)); reader.setLenient(true); global.puller.storedData.dictionary = gson.fromJson(reader, WordDictionary.class); global.puller.storedData.dictionary.index = new HashMap(); for (int i = 0; i < global.puller.storedData.dictionary.entries.size(); i++) { global.puller.storedData.dictionary.index.put(global.puller.storedData.dictionary.entries.get(i).systemword, global.puller.storedData.dictionary.entries.get(i).translation); } global.textColor = Color.parseColor(global.puller.storedData.carrierCi.foreGround); ret = "alldone"; } catch (Exception e) { e.printStackTrace(); } return ret; } protected void onPostExecute(String result) { if (result.equals("alldone")) { global.puller.saveStoredData(); Intent newIntent = new Intent(MainActivity.this, Login.class); startActivity(newIntent); }else createErrorDialog("Server Error.", () -> startApiTask(usedCarrierCiID)); } } } package at.inntelco.INNTEL; import android.app.NotificationManager; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.widget.Toast; import org.linphone.core.Reason; import at.inntelco.INNTEL.home.CallingScreen; public class NotificationReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { INNTELApplication application = (INNTELApplication) context.getApplicationContext(); Global global = application.global; String action = intent.getAction(); if (action != null) { switch (action) { case "Accept": System.out.println("a"); Intent newIntent = new Intent(context, CallingScreen.class); newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); newIntent.setAction("Accept"); context.startActivity(newIntent); break; case "Decline": INNTELApplication.coreContext.core.getCurrentCall().decline(Reason.Busy); if(global.puller.storedData.callList.size()>0) global.puller.storedData.callList.get(global.puller.storedData.callList.size()-1).success=false; global.puller.saveStoredData(); System.out.println("b"); break; } NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.cancel(0); } } } package at.inntelco.INNTEL; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.os.AsyncTask; import android.util.Log; import android.widget.ImageView; import org.json.JSONObject; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStream; import java.io.InputStreamReader; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.net.URL; import java.net.URLEncoder; import java.util.LinkedHashMap; import java.util.concurrent.ExecutorService; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import javax.net.ssl.HttpsURLConnection; public class Puller { public StoredData storedData; public Global global; public ExecutorService theExecutor; public Puller(Global global) { this.global = global; theExecutor = new ThreadPoolExecutor(200,200,0L, TimeUnit.MILLISECONDS,new LinkedBlockingQueue()); } public boolean fileExists(String name) { boolean ret = false; File file = new File(global.saveDirNameAbsolute + "/" + name); ret = file.exists(); return ret; } public void loadStoredData() { try { FileInputStream fileIn = new FileInputStream(global.saveFileName); ObjectInputStream objectIn = new ObjectInputStream(fileIn); storedData = (StoredData) objectIn.readObject(); } catch (Exception e) { e.printStackTrace(); } } public void resetAll() { String thePath = global.saveDirNameAbsolute; File file = new File(thePath); file.delete(); File file2 = new File(global.saveFileName); file2.delete(); storedData=null; } public void deleteFile(String name) { String thePath = global.saveDirNameAbsolute + "/" + name; File file = new File(thePath); if (file.isDirectory()) System.out.println("file " + name + " could not be deleted, it is a directory"); else { if (file.exists()) { if (file.delete()) System.out.println("file " + name + " deleted."); else System.out.println("deletion of file " + name + " failed"); } else { System.out.println("file " + name + " could not be deleted, it does not exist."); } } } public String webserviceCall(String command, LinkedHashMap params, boolean encode,String apiKey, String jwtBearer) { System.out.println("WEBSERVICECALL !!! "+command); long now = System.currentTimeMillis(); String ret = ""; String theUrl = global.puller.storedData.apiServerUrl + "/" + command; HttpsURLConnection connection = null; BufferedReader reader = null; try { URL url = new URL(theUrl); connection = (HttpsURLConnection) url.openConnection(); connection.setRequestMethod("POST"); connection.setDoInput(true); connection.setDoOutput(true); connection.setRequestProperty("Content-Type", "application/json"); connection.setRequestProperty("x-mock-match-request-body", "true"); connection.setRequestProperty("cache-control", "no-cache"); connection.setRequestProperty("Accept", "application/json"); if(null!=apiKey) connection.setRequestProperty("X-API-Key",apiKey); if(null!=jwtBearer) connection.setRequestProperty("Authorization", "Bearer "+jwtBearer); JSONObject json = new JSONObject(); for (String key : params.keySet()) { String val = params.get(key); if(encode) json.put(URLEncoder.encode(key, "UTF-8"), URLEncoder.encode(val, "UTF-8")); else json.put(URLEncoder.encode(key, "UTF-8"), val); } OutputStream os = connection.getOutputStream(); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os, "UTF-8")); writer.write(json.toString()); writer.flush(); writer.close(); os.close(); connection.connect(); InputStream stream = connection.getInputStream(); reader = new BufferedReader(new InputStreamReader(stream)); StringBuilder builder = new StringBuilder(); String line = ""; while ((line = reader.readLine()) != null) { builder.append(line); } stream.close(); ret = builder.toString(); } catch (Exception e) { e.printStackTrace(); } finally { if (connection != null) { connection.disconnect(); } try { if (reader != null) { reader.close(); } } catch (Exception e) { e.printStackTrace(); } long later = System.currentTimeMillis(); long diff = later - now; System.out.println(diff + " millis."); } return ret; } public String createUniqueName() { int random = Utilities.getRandomNumberInRange(1, 1000000); String ret = "miFile" + storedData.uniqueId + "" + random; storedData.uniqueId++; saveStoredData(); return ret; } public void downloadFile(String originUrl, String destination) { destination = global.saveDirNameAbsolute + "/" + destination; new LoadFileTask().execute(originUrl, destination); } public void saveStoredData() { try { FileOutputStream fileOut = new FileOutputStream(global.saveFileName); ObjectOutputStream objectOut = new ObjectOutputStream(fileOut); objectOut.writeObject(storedData); objectOut.close(); } catch (Exception e) { e.printStackTrace(); } } public void loadImage(ImageView theImage, String sourceRemote, String sourceLocal, BetterActivity motherThatShowsLoadingScreenUntilFinished) { String thePath = global.saveDirNameAbsolute + "/" + sourceLocal; System.out.println("sourceremote:"+sourceRemote+" sourcelocal:"+sourceLocal); File file = new File(thePath); if (file.isDirectory()) System.out.println("image " + thePath + " could not be loaded, it is a directory"); else { if (file.exists()) { System.out.println("STARTING LOCAL IMG LOAD " + sourceRemote); new LoadImageTask(theImage, motherThatShowsLoadingScreenUntilFinished).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, thePath); } else { System.out.println("STARTING REMOTE IMG LOAD " + sourceRemote); new LoadImageTask(theImage, motherThatShowsLoadingScreenUntilFinished).executeOnExecutor(theExecutor, sourceRemote); } } } public void loadImageWithGuiAlreadyShowing(ImageView theImage, String sourceRemote, String sourceLocal) { loadImage(theImage, sourceRemote, sourceLocal, null); } private class LoadImageTask extends AsyncTask { ImageView bmImage; BetterActivity mother; public LoadImageTask(ImageView bmImage, BetterActivity mother) { this.bmImage = bmImage; this.mother = mother; if (mother != null) mother.waitForThisBeforeHidingLoadingScreen(); } protected Bitmap doInBackground(String... source) { String url = source[0]; Bitmap bmp = null; try { InputStream in; if (!url.startsWith("http")) { File file = new File(url); in = new FileInputStream(file); } else in = new URL(url).openStream(); bmp = BitmapFactory.decodeStream(in); } catch (Exception e) { Log.e("Error", e.getMessage()); e.printStackTrace(); } return bmp; } protected void onPostExecute(Bitmap result) { if (mother != null) mother.decreaseThingsToWaitForAndHideLoadingScreen(); bmImage.setImageBitmap(result); } } private class LoadFileTask extends AsyncTask { public LoadFileTask() { } protected Void doInBackground(String... obj) { String source = obj[0]; String target = obj[1]; InputStream input = null; OutputStream output = null; try { input = new URL(source).openStream(); output = null; output = new FileOutputStream(target); byte data[] = new byte[4096]; long total = 0; int count; while ((count = input.read(data)) != -1) { total += count; output.write(data, 0, count); } } catch (Exception e) { Log.e("Error", e.getMessage()); e.printStackTrace(); } finally { try { if (output != null) output.close(); if (input != null) input.close(); } catch (Exception ignored) { } } return null; } protected void onPostExecute() { } } } package at.inntelco.INNTEL; import android.Manifest; import android.content.Intent; import android.content.pm.PackageManager; import android.os.Bundle; import androidx.appcompat.app.AppCompatActivity; import androidx.core.app.ActivityCompat; import at.inntelco.INNTEL.home.CallingScreenLocked; import at.inntelco.INNTEL.home.Contacts; public class SplashActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = new Intent(this, MainActivity.class); startActivity(intent); finish(); } } package at.inntelco.INNTEL; import at.inntelco.INNTEL.data.CallEntity; import at.inntelco.INNTEL.data.CarrierCi; import at.inntelco.INNTEL.data.LoginInfo; import at.inntelco.INNTEL.data.User; import at.inntelco.INNTEL.data.WordDictionary; import java.io.Serializable; import java.util.ArrayList; public class StoredData implements Serializable { private static final long serialVersionUID = 1L; public int uniqueId = 0; public CarrierCi carrierCi; public WordDictionary dictionary; public LoginInfo loginInfo; public User user; public ArrayList callList; public boolean firstLoginDone = false; public CallEntity callEntity; public boolean testSystemChosen = true; public String apiServerUrl = "XXX"; public String vorWahl = ""; public int avatarDropdownSelection = 0; } package at.inntelco.INNTEL; import android.content.Context; import android.content.pm.PackageManager; import android.content.res.ColorStateList; import android.graphics.Bitmap; import android.graphics.Bitmap.Config; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.Path; import android.graphics.PorterDuff; import android.graphics.PorterDuff.Mode; import android.graphics.PorterDuffXfermode; import android.graphics.Rect; import android.graphics.RectF; import com.google.android.material.bottomnavigation.BottomNavigationView; import android.graphics.drawable.Drawable; import android.graphics.drawable.LayerDrawable; import android.view.Menu; import android.widget.EditText; import androidx.core.content.ContextCompat; import java.nio.channels.Selector; import java.text.SimpleDateFormat; import java.util.Date; import java.util.LinkedHashMap; import java.util.Locale; import java.util.Random; public class Utilities { public static Object getElementAt(LinkedHashMap map, int index) { return map.get((map.keySet().toArray())[index]); } public static String fromRGBA(int r, int g, int b, int a) { return "#" + toBrowserHexValue(a) + toBrowserHexValue(r) + toBrowserHexValue(g) + toBrowserHexValue(b); } private static String toBrowserHexValue(int number) { StringBuilder builder = new StringBuilder(Integer.toHexString(number & 0xff)); while (builder.length() < 2) { builder.append("0"); } return builder.toString().toUpperCase(); } public static String nullToEmptyString(String word) { String ret = ""; if (null != word) ret = word; return ret; } public static int getRandomNumberInRange(int min, int max) { Random r = new Random(); return r.nextInt((max - min) + 1) + min; } public static String removeLeadingSpaces(String word) { String ret = word; for (int i = 0; i < word.length(); i++) { if (("" + word.charAt(i)).equals(" ")) { if (word.length() > i) ret = word.substring(i + 1); } else break; } return ret; } public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, int pixels) { Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap .getHeight(), Config.ARGB_8888); Canvas canvas = new Canvas(output); final int color = 0xff424242; final Paint paint = new Paint(); final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); final RectF rectF = new RectF(rect); final float roundPx = pixels; paint.setAntiAlias(true); canvas.drawARGB(0, 0, 0, 0); paint.setColor(color); canvas.drawRoundRect(rectF, roundPx, roundPx, paint); paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN)); canvas.drawBitmap(bitmap, rect, rect, paint); return output; } public static String normalizeNumber(String telNr, String myCountryPrefixTwoDigits) { telNr = telNr.replaceAll(" ", ""); if (telNr.startsWith("++") || telNr.startsWith("00")) { telNr = telNr.substring(2); telNr = "+" + telNr; } if (telNr.startsWith("+" + myCountryPrefixTwoDigits)) { telNr = telNr.substring(3); telNr = "0" + telNr; } return telNr; } public static boolean hasPermission(Context context, String permissionString){ boolean perm = false; perm = (context.getPackageManager().checkPermission( permissionString, context.getPackageName() ) == PackageManager.PERMISSION_GRANTED); return perm; } public static String humanReadableDate(Date date) { SimpleDateFormat sdf = new SimpleDateFormat("HH:mm dd.MM.yyyy", Locale.getDefault()); return sdf.format(date); } public static void replaceSelectedText(EditText headLine, String replacement, String defaultText, boolean backSpace) { int startSelection = headLine.getSelectionStart(); int endSelection = headLine.getSelectionEnd(); String text = headLine.getText().toString(); if (!defaultText.equals(text)) { if (startSelection != endSelection) { text = text.substring(0, startSelection) + replacement + text.substring(endSelection); } else { if (backSpace) { if (text.length() > 0) { text = text.substring(0, text.length() - 1); } } else { text = text + replacement; } } }else{ if(!backSpace) text = replacement; } if (text.length() == 0) text = defaultText; headLine.setText(text); } public static Bitmap triangleFromColor(int color, int height, int width) { Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); Paint paint = new Paint(); paint.setColor(color); paint.setStyle(Paint.Style.FILL); Path path = new Path(); path.moveTo(width, 0); path.lineTo(width, height); path.lineTo(0, height / 2); path.close(); canvas.drawPath(path, paint); return bitmap; } public static void createMenu(BottomNavigationView navigation, Global global) { Menu menu = navigation.getMenu(); if (!menu.hasVisibleItems()) { menu.add(Menu.NONE, R.id.navigation_contacts, Menu.NONE, global.getTranslation("Contacts")) .setIcon(R.drawable.menu_contacts_active); menu.add(Menu.NONE, R.id.navigation_history, Menu.NONE, global.getTranslation("History")) .setIcon(R.drawable.menu_history_active); menu.add(Menu.NONE, R.id.navigation_dial, Menu.NONE, global.getTranslation("Dial")) .setIcon(R.drawable.menu_dial_active); menu.add(Menu.NONE, R.id.navigation_settings, Menu.NONE, global.getTranslation("Settings")) .setIcon(R.drawable.menu_settings_active); } ColorStateList iconTintList = ColorStateList.valueOf(Color.parseColor(global.puller.storedData.carrierCi.foreGround)); menu.getItem(0).setIconTintList(iconTintList); } }