Skip to content

James-Z-Zhang00/Dialer

Repository files navigation

Dialer

An Android app for making phone calls with customized UI, device optimization and multilingual support.

General Structure

The project was made by 3 parts:

  • .xml UI design
  • Back end Java logic
  • Manifest file & other meta data

.xml UI Design

The portrait and view, button labels are beautified by spannableString

Screen Shot 2024-05-29 at 12 07 18 PM

The landscape view

Screen Shot 2024-05-29 at 12 07 09 PM

The UI was built by nested LinearLayout, scales are vary for different screen sizes

Screen Shot 2024-05-29 at 12 09 40 PM

Back End Java Logic

Check if the app has CALL ACTION promission, if not ask the user to give promission and the following operations

private void askForCallPermission() {
        ActivityCompat.requestPermissions(MainActivity.this,
                new String[] {Manifest.permission.CALL_PHONE},
                CALL_PERMISSION_REQUEST_CODE);
    }

@Override
    public void onRequestPermissionsResult(int requestCode, String[] permissions,
                                           int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);

        if (grantResults.length > 0 &&
                grantResults[0] == PackageManager.PERMISSION_GRANTED) {
            makeCall();
        } else {
            makeToast("Allow the permission to make call!");
        }
    }

Clipboard feature to allow user copy the entered number for future process

private void copyToClipboard() {
        ClipboardManager cb = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
        ClipData clip = ClipData.newPlainText("number",dialNumber.getText().toString());
        cb.setPrimaryClip(clip);
        makeToast("Number copied to clipboard!");
    }

Button components initialization

btn0.setOnClickListener(l -> addNumber("0"));
btn1.setOnClickListener(l -> addNumber("1"));

Button beautification, where button object will be passed as parameter

private void formatBtn(Button btn) {
        String btnLabel = btn.getText().toString();
        //StyleSpan bss = new StyleSpan(Typeface.BOLD);
        SpannableString ss = new SpannableString(btnLabel);
        AbsoluteSizeSpan ass = new AbsoluteSizeSpan(20,true);
        AbsoluteSizeSpan assAfter = new AbsoluteSizeSpan(10,true);
        ss.setSpan(ass,0,1, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
        //ss.setSpan(bss,0,1, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
        ss.setSpan(assAfter,1,btnLabel.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
        btn.setText(ss);
    }

Screen modification to hide the top action bar for more spaces

if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
            requestWindowFeature(Window.FEATURE_NO_TITLE);
            this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
            getSupportActionBar().hide();
        }

Manifest File & Other Meta Data

Some basic information about the app and icon setting

<application
        android:allowBackup="true"
        android:dataExtractionRules="@xml/data_extraction_rules"
        android:fullBackupContent="@xml/backup_rules"
        android:icon="@mipmap/ic_icon"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_icon_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.Dialer"
        tools:targetApi="31">
        <activity
            android:name=".MainActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

Multilingual support

Use variables for each string

<string name="app_name">Dialer</string>
<string name="call">Call</string>
<string name="del">Del</string>
<string name="copy">Copy Number</string>

The supported languages: English, German, Russian and Spanish

Screen Shot 2024-05-29 at 1 25 18 PM

The language of the app will change as the system settings change

Screen Shot 2024-05-29 at 1 27 25 PM Screen Shot 2024-05-29 at 1 39 16 PM

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages